/* * add user to the UserDictionary */ public bool addUser(string name) { if (!UserDictionary.ContainsKey(name)) { userInfo tempInfo = new userInfo(); tempInfo.cashBalance = 1000; UserDictionary.Add(name, tempInfo); return true; } else { return false; } }
public async Task <OperationResult <userInfo> > GetByIdAsync(string id) { userInfo userInfo = await userRepo.GetByIdAsync(id); if (userInfo != null) { return(new OperationResult <userInfo>() { Success = true, Message = Messages.USER_SUCCESS, Result = userInfo }); } return(new OperationResult <userInfo>() { Success = false, Message = Messages.USER_NOT_EXIST + " (" + id + ")" }); }
/// <summary> /// 往用户信息表中插入数据 /// </summary> /// <param name="info"></param> /// <returns></returns> public static Boolean insertUserInfo(userInfo info) { try { using (LazyfitnessEntities db = new LazyfitnessEntities()) { db.userInfo.Add(info); db.SaveChanges(); return(true); } } catch { return(false); } }
// GET: userInfoes/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } userInfo userInfo = await db.userInfo.FindAsync(id); if (userInfo == null) { return(HttpNotFound()); } ViewBag.docId = new SelectList(db.Doctor, "doctorId", "name", userInfo.docId); ViewBag.userId = new SelectList(db.User, "userId", "password", userInfo.userId); return(View(userInfo)); }
public UserInfoPage() { InitializeComponent(); fechaNacimiento.MaximumDate = DateTime.Parse(DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString() + "-" + (DateTime.Now.Year - 18).ToString()); Repository repo = new Repository(); string token = App.Current.Properties["token"].ToString(); userInfo user = repo.postUserInfo(token).Result; nombre.Text = user.data.Name; apellido.Text = user.data.LastName; ciudad.Text = user.data.City; telefono.Text = user.data.CellNumber; }
public userInfo getUserInfo(string email) { string DatabaseConnectionString = ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString; using (SqlConnection sqlConn = new SqlConnection(DatabaseConnectionString)) { string sqlStatement = "SELECT * FROM userInfo WHERE email = @paraEmail"; using (SqlDataAdapter da = new SqlDataAdapter(sqlStatement, sqlConn)) { da.SelectCommand.Parameters.AddWithValue("@paraEmail", email); using (DataSet ds = new DataSet()) { try { da.Fill(ds); userInfo uif = null; int rec_cnt = ds.Tables[0].Rows.Count; if (rec_cnt == 1) { DataRow row = ds.Tables[0].Rows[0]; //string email = row["email"].ToString(); string firstName = row["firstName"].ToString(); string lastName = row["lastName"].ToString(); string passwordHash = row["passwordHash"].ToString(); string passwordSalt = row["passwordSalt"].ToString(); DateTime lastUpdate = Convert.ToDateTime(row["lastUpdate"].ToString()); byte[] iv = Convert.FromBase64String(row["IV"].ToString()); byte[] key = Convert.FromBase64String(row["Key"].ToString()); uif = new userInfo(email, firstName, lastName, passwordHash, passwordSalt, lastUpdate, iv, key); } return(uif); } catch (SqlException ex) { throw new Exception(ex.ToString()); } finally { Debug.WriteLine("Retrieve userInfo complete!"); } } } } }
/* * FUNCTION : ClientThread * * DESCRIPTION : The main loop that will listen for messages from the client * and deal with messages appropriately * * PARAMETERS : userInfo client - A struct containing the client's information * * RETURNS : nothing */ private void ClientThread(userInfo client) { clientList.Add(client); //Send a list of connected users to all clients ListUsers(null); while (true) { message newMessage = (message)client.fromClient.Receive().Body; if ((newMessage.body != null) || (newMessage.type == messageType.disconnect)) { switch (newMessage.type) { case messageType.text: //If a message was reicieved, redistribute to all clients SendMessages("[" + client.username + "]: " + newMessage.body); break; case messageType.listUsers: //Send a list of connected users to only this client ListUsers(client.toClient); break; case messageType.disconnect: //Client DCing, delete local message queue and remove client from list clientList.Remove(client); //log - user disconnected & message queue deleted Logging.NewLogEvent($"User disconnected from server. Username: {client.username}"); Logging.NewLogEvent($"Local Message Queue deleted: {client.fromClient.Path}"); MessageQueue.Delete(client.fromClient.Path); //MessageQueue.Remove //Send new client list to all clients to reflect DCed client ListUsers(null); return; } } } }
public ActionResult Login(userInfo Info) { bool AdminisValid = context.userInfoes.Any(x => x.Email == Info.Email && x.Password == Info.Password && x.Type == "Admin"); bool ModeratorValid = context.userInfoes.Any(x => x.Email == Info.Email && x.Password == Info.Password && x.Type == "Moderator"); bool DonorisValid = context.userInfoes.Any(x => x.Email == Info.Email && x.Password == Info.Password && x.Type == "Donor"); bool BanCheck = context.bannedUsers.Any(x => x.Email == Info.Email); if (AdminisValid || DonorisValid) { Session["Email"] = Info.Email; } if (AdminisValid && !BanCheck) { //FormsAuthentication.SetAuthCookie(Info.Email, false); Session["Type"] = "Admin"; return(RedirectToAction("Index", "Admin", new { email = Info.Email })); } if (ModeratorValid && !BanCheck) { //FormsAuthentication.SetAuthCookie(Info.Email, false); Session["Type"] = "Moderator"; //return RedirectToAction("Index", "Admin", new { email = Info.Email }); } if (DonorisValid && !BanCheck) { FormsAuthentication.SetAuthCookie(Info.Email, false); TempData["errorLogin"] = "******"; //return RedirectToAction("Index"); } if (BanCheck && (AdminisValid || ModeratorValid || DonorisValid)) { TempData["errorLogin"] = "******"; } TempData["errorLogin"] = "******"; Session["Type"] = "Admin"; // return RedirectToAction("Login"); return(RedirectToAction("Index", "Admin", new { email = Info.Email })); }
protected void Save_Click(object sender, EventArgs e) { userInfo s = new userInfo(); //身份证号 s.Uid = CardId.Text; //姓名 s.Uname = UserName.Text; //性别 if (Sex1.Checked) { s.Usex = Sex1.Text; } if (Sex2.Checked) { s.Usex = Sex2.Text; } //出生日期 string str = (DropDownList1.Text + "-" + DropDownList2.Text + "-" + DropDownList3.Text).ToString(); DateTime date = Convert.ToDateTime(str); s.Ubirthday = date; //电子邮箱 s.Uemail = Email.Text; if (user.isImproved(CardId.Text)) //如果完善过个人信息 { user.updateUserInfo(s, CardId.Text); //修改记录 } else { user.addUserInfo(s);//向用户信息表插入一条新记录 } UpdateButton.Visible = true; SaveButton.Visible = false; UserName.Enabled = false; Sex1.Enabled = false; Sex2.Enabled = false; DropDownList1.Enabled = false; DropDownList2.Enabled = false; DropDownList3.Enabled = false; Email.Enabled = false; Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('保存成功!');</script>"); }
//Used to get all the different types of budget code form the DB public List <budgetCodes> getBudgetCodes(userInfo user) { List <budgetCodes> budgetInfo = new List <budgetCodes>(); if (this.OpenConnection() == true) { using (MySqlCommand dbCMD = new MySqlCommand()) { dbCMD.Connection = sqlConn; if (user.userType.Contains("SWF") || user.userType.Contains("SE")) { dbCMD.CommandText = "SELECT * FROM budgetInfo WHERE districtCode=0 "; } else { dbCMD.CommandText = "SELECT * FROM budgetInfo WHERE districtCode=1 "; } dbCMD.ExecuteNonQuery(); using (MySqlDataReader rdr = dbCMD.ExecuteReader()) { while (rdr.Read()) { budgetCodes tempCode = new budgetCodes(); tempCode.budgetName = rdr[0].ToString(); tempCode.budgetCode = rdr[1].ToString(); tempCode.budgetDescription = rdr[2].ToString(); tempCode.district = rdr[3].ToString(); budgetInfo.Add(tempCode); } } } this.CloseConnect(); return(budgetInfo); } else { this.CloseConnect(); MessageBox.Show("Error connecting to DB. Contact Admin"); } return(budgetInfo); }
public IActionResult EditInfo([FromBody] userInfo userInfoToUpdate) { if (userInfoToUpdate == null || userInfoToUpdate.id == 0) { return(Json(new { statusCode = ResponseStatus.ValidationError })); } try { User user = facebookDataContext.Users.Where(u => u.Id == userInfoToUpdate.id).FirstOrDefault(); if (user == null) { return(Json(new { statusCode = ResponseStatus.NoDataFound })); } user.Bio = userInfoToUpdate.Bio; user.PhoneNumber = userInfoToUpdate.PhoneNumber; user.BirthDate = userInfoToUpdate.BirthDate; if (userInfoToUpdate.GenderName == "Male") { user.GenderId = 1; } else // female { user.GenderId = 2; } string[] nameSplitted = userInfoToUpdate.FullName.Split(" "); // to get first, last name user.FirstName = nameSplitted[0]; user.LastName = nameSplitted[1]; facebookDataContext.SaveChanges(); // Saving user for session userData.SetUser(HttpContext, user); return(Json(new { statusCode = ResponseStatus.Success })); } catch (Exception) { return(Json(new { statusCode = ResponseStatus.Error })); } }
/// <summary> /// 查找用户信息表中符合条件的信息 /// </summary> /// <param name="whereLambda"></param> /// <returns></returns> public static userInfo[] selectUserInfo <TKey>(Expression <Func <userInfo, bool> > whereLambda, Expression <Func <userInfo, TKey> > orderBy) { try { using (LazyfitnessEntities db = new LazyfitnessEntities()) { DbQuery <userInfo> dataObject = db.userInfo.Where(whereLambda).OrderBy(orderBy) as DbQuery <userInfo>; userInfo[] infoList = dataObject.ToArray(); return(infoList); } } catch { userInfo[] nullInfo = new userInfo[0]; return(nullInfo); } }
/// <summary> /// 增加用户 /// </summary> /// <param name="user"></param> public void Add(userInfo user) { //ISession session = NhibernateHelper.openSession(); //session.Save(user); //session.Close(); //调用NhibernateHelper 辅助类中的方法 会自动关闭 using (ISession session = NhibernateHelper.openSession()) { //开启一个事务 会自动释放 using (ITransaction transaction = session.BeginTransaction()) { session.Save(user); //保存user transaction.Commit(); //事务的提交 } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["userid"] == null || Session["userid"].ToString() == "") { Response.Redirect("login.aspx"); } string userId = Session["userid"].ToString(); starweibo.BLL.userInfo blluserInfo = new userInfo(); List <starweibo.Model.userInfo> userInfos = blluserInfo.GetModelList("id!=44 and id!=" + userId + " and id not in(select friendId from relationInfo where userId=" + userId + ")"); //List<starweibo.Model.userInfo> userInfosn = blluserInfo.GetModelList("id in (select friendId from relationInfo where userId=2)"); //List<starweibo.Model.userInfo> userInfosnn = blluserInfo.GetModelList("id not in (select friendId from relationInfo where userId=2)"); //userInfosn.Add(userInfosnn[0]); this.focusInfo.DataSource = userInfos; this.focusInfo.DataBind(); }
public List <userInfo> buscar_usuario(string query) { using (DatabaseClient dbClient = Environment.GetDatabase().GetClient()) { List <userInfo> user_result = new List <userInfo>(); dbClient.AddParamWithValue("@query", query); DataTable dTable = dbClient.ReadDataTable("SELECT * FROM usuarios WHERE usuario = @query LIMIT 1"); foreach (DataRow dRow in dTable.Rows) { userInfo User = Environment.Game.User.getUser(int.Parse(dRow["id"].ToString())); if (User != null) { user_result.Add(User); } } return(user_result); } }
//Insert new User from Admin Program public bool InsertUserAdmin(userInfo newUser) { if (this.OpenConnection() == true) { using (MySqlCommand dbCMD = new MySqlCommand()) { dbCMD.Connection = sqlConn; dbCMD.CommandText = "INSERT INTO `userInfo`(`userID`, `userLastName`, `userFirstName`, `userEmail`, `userPhoneNumber`, `accountActive`, `workerType`, `department`, `lastSSN`, `jobTitle`) " + $"VALUES (\"{newUser.userID}\",\"{newUser.lastName}\",\"{newUser.firstName}\",\"{newUser.userEmail}\",\"{newUser.userPhoneNum}\",1,\"{newUser.userType}\",\"{newUser.department}\",\"{newUser.lastSSN}\",\"{newUser.jobTitle}\")"; dbCMD.ExecuteNonQuery(); } return(true); } return(false); }
public string updateUserInfo(userInfo info) { try { if (toolsHelpers.updateToolsController.updateUserInfo(u => u.userId == info.userId, info) == true) { Response.Redirect("/backStage/userManagement/Index"); return("success"); } else { return("修改失败"); } } catch { return("false"); } }
static void Main(string[] args) { string publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDTT1ryGLfq5lucyHdzPLbjtcVsgurf5x4Y09U/cTiV85duIk0zQeRTXNyGcMAS92+xV/eGp7IjncwL8QE8JqlclLvuOU3zTdlAQ58lu/JcTcsF6eA6JXb8OJAhmDoug1J77M2GLoqAl0Cf34kavj/r9bAQpWqbk8JlJU3YqIePuwIDAQAB"; RSAForJava rsa = new RSAForJava(); userInfo u = new userInfo(); u.channelUserCode = "e5d1a2ca4883474791ca91ce20c90014"; u.userName = "******"; u.phone = "15989287032"; u.idName = "银联"; u.email = ""; u.channelCompanyCode = ""; string input = Newtonsoft.Json.JsonConvert.SerializeObject(u); String encry = rsa.EncryptByPublicKey(input, publicKey); }
/// <summary> /// 判断是否是管理员 /// </summary> /// <param name="userId">用户ID</param> /// <returns></returns> public static bool IsAdmin(string userId) { int id; if (Int32.TryParse(userId, out id) == false) { return(false); } userInfo info = Tools.GetUserInfo(id); if (info != null && info.userStatus == 3) { return(true); } else { return(false); } }
public void QuestionSubmit(int areaId, int userId, string title, string editor, int money) { userInfo info = Tools.GetUserInfo(userId); if (info.userAccount == null) { info.userAccount = 0; } if (info.userAccount < money) { money = (int)info.userAccount; } else { using (LazyfitnessEntities db = new LazyfitnessEntities()) { DbQuery <userInfo> dbsearch = db.userInfo.Where(u => u.userId == userId) as DbQuery <userInfo>; userInfo _userinfo = dbsearch.FirstOrDefault(); _userinfo.userAccount -= money; db.SaveChanges(); } } quesAnswInfo qaInfo = new quesAnswInfo { areaId = areaId, quesAnswTitle = title, userId = userId, quesAnswTime = DateTime.Now, pageView = 0, isPost = 0, quesAnswStatus = 1, amount = money, quesAnswContent = editor }; using (LazyfitnessEntities db = new LazyfitnessEntities()) { db.quesAnswInfo.Add(qaInfo); db.SaveChanges(); Response.Redirect(Url.Action("QuestionPart", "Home", new { partId = areaId })); } }
protected bool setUsername() { if (isLoggedIn()) { uInfo = (userInfo)Session["_di09USR"]; ((Label)Master.FindControl("lblUserName")).Text = uInfo.UserName; ((HyperLink)Master.FindControl("linkProfile")).Visible = true; ((HyperLink)Master.FindControl("linkLogout")).Visible = true; ((HyperLink)Master.FindControl("linkPrivate")).Visible = true; return true; } else { ((Label)Master.FindControl("lblUserName")).Text = DEFAULTUSER; ((HyperLink)Master.FindControl("linkProfile")).Visible = false; ((HyperLink)Master.FindControl("linkLogout")).Visible = false; ((HyperLink)Master.FindControl("linkPrivate")).Visible = false; return false; } }
public HttpResponseMessage PostUsers(userInfo user) { Users users = new Users(); users.fullName = user.fullName; users.idNumber = user.idNumber; users.userName = user.userName; users.password = user.password; users.userType = user.userType; users.gender = user.gender; users.email = user.email; users.birthDate = user.birthDate; users.pic = user.pic; db.Users.Add(users); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); }
//注册 返回是否注册成功 public JsonResult SignUp(string username, string password, string email) { //添加用户名不能重复 userInfo[] list = SqlHelper.GetInfo <userInfo, int>(u => u.name == username, a => a.userId); if (list.Length != 0) { return(Json(false, JsonRequestBehavior.AllowGet)); } userInfo info = new userInfo { name = username, psw = password, email = email, userHeaderPic = "/res/DefaultHead.jpg", isEnable = 0 }; bool IsSuccess = SqlHelper.Insert <userInfo>(info); return(Json(IsSuccess, JsonRequestBehavior.AllowGet)); }
protected bool setUsername() { if (isLoggedIn()) { uInfo = (userInfo)Session["_di09USR"]; ((Label)Master.FindControl("lblUserName")).Text = uInfo.UserName; ((HyperLink)Master.FindControl("linkProfile")).Visible = true; ((HyperLink)Master.FindControl("linkLogout")).Visible = true; ((HyperLink)Master.FindControl("linkPrivate")).Visible = true; return(true); } else { ((Label)Master.FindControl("lblUserName")).Text = DEFAULTUSER; ((HyperLink)Master.FindControl("linkProfile")).Visible = false; ((HyperLink)Master.FindControl("linkLogout")).Visible = false; ((HyperLink)Master.FindControl("linkPrivate")).Visible = false; return(false); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["isLogin"] == null || Session["isLogin"].ToString() != "true") { Response.Redirect("./Movie.aspx"); } UserName = Session["username"].ToString(); userInfo u = userService.GetUserInfo(UserName); UserGender = u.userGender.ToString(); UserPic = u.userPic; if (u.userBir != null) { UserBir = u.userBir; } else { UserBir = ""; } }
public int Index(userInfo obj) { userInfo user = new userInfo(); try { SqlConnection con = new SqlConnection(); con.ConnectionString = ConfigurationManager.ConnectionStrings["EcommerceCon"].ConnectionString; if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "pSMWEditProfile"; cmd.CommandType = CommandType.StoredProcedure; if (obj.mobile == null) { obj.mobile = ""; } if (obj.pincode == null) { obj.pincode = ""; } cmd.Parameters.Add("@username", SqlDbType.VarChar).Value = obj.username.ToString(); cmd.Parameters.Add("@mac", SqlDbType.VarChar).Value = obj.mac_address.ToString(); cmd.Parameters.Add("@mobile", SqlDbType.VarChar).Value = obj.mobile.ToString(); cmd.Parameters.Add("@email", SqlDbType.VarChar).Value = obj.email_phone.ToString(); cmd.Parameters.Add("@address", SqlDbType.VarChar).Value = obj.address.ToString(); cmd.Parameters.Add("@city", SqlDbType.VarChar).Value = obj.city.ToString(); cmd.Parameters.Add("@state", SqlDbType.VarChar).Value = obj.state.ToString(); cmd.Parameters.Add("@pin", SqlDbType.VarChar).Value = obj.pincode.ToString(); cmd.ExecuteNonQuery(); con.Close(); } catch (Exception e) { return(0); } return(1); }
public string register(userSecurity security, userInfo info) { //使用entity framework 进行数据的插入 try { using (LazyfitnessEntities db = new LazyfitnessEntities()) { var isLoginID = db.userSecurity.Where <userSecurity>(u => u.loginId == info.userName.Trim()); if (isLoginID.ToList().Count != 0) { return("已经有账户"); } userSecurity obSecurity = new userSecurity { loginId = info.userName.Trim(), userPwd = MD5Helper.MD5Helper.encrypt(security.userPwd.Trim()), }; db.userSecurity.Add(obSecurity); db.SaveChanges(); int uniformId; DbQuery <userSecurity> dbSecuritySureUserId = db.userSecurity.Where(u => u.loginId == info.userName.Trim()) as DbQuery <userSecurity>; userSecurity dbSecurity = dbSecuritySureUserId.FirstOrDefault(); uniformId = dbSecurity.userId; userInfo obInfo = new userInfo { userId = uniformId, userName = info.userName.Trim(), userAge = info.userAge, userSex = info.userSex, userTel = info.userTel.Trim(), }; db.userInfo.Add(obInfo); db.SaveChanges(); } return("T"); } catch (Exception ex) { return(ex.ToString()); } }
public Task deleteLiker(userInfo user, question question) { return(Task.Factory.StartNew(() => { var userId = new SqlParameter("userId", SqlDbType.VarChar); userId.Value = user.id; var questionId = new SqlParameter("questionId", SqlDbType.Int); questionId.Value = question.id; try { context.Database.ExecuteSqlCommand("EXEC delete_question_Liker @userId,@questionId", userId, questionId); return; } catch (SqlException ex) { throw new ArgumentException(ex.Message); } })); }
protected override void OnPreInit(EventArgs e) { if (Context.Session != null) { if (Session["_di09USR"] != null) { userInfo uInfo = (userInfo)Session["_di09USR"]; //EXIT USER FROM ANY PRE CHATROOMS PublicChat pObj = new PublicChat(); pObj.User_id = uInfo.UserId; pObj.LeaveChatRoom(); LoginCls logoutObj = new LoginCls(); logoutObj.LogOut(uInfo.UserId); } } Session.Abandon(); Response.Redirect("~/home.aspx", true); }
public ActionResult update(userInfo info) { try { userInfo[] List = toolsHelpers.selectToolsController.selectUserInfo(u => u.userId == info.userId, u => u.userId); if (List == null) { return(Content("查询用户失败")); } userInfo userInformation = List[0]; ViewBag.userInformation = userInformation; //获取用户状态表中的数据 userStatusName[] nameArray = toolsHelpers.selectToolsController.selectUserStatusName(x => x == x, u => u.userStatus); ViewBag.nameArray = nameArray; return(View()); } catch { return(Content("查询用户出错")); } }
public bool AddUser(string name, string pwd, string email) { try { userInfo user = new userInfo(); user.userName = name; user.userPass = pwd; user.userEmail = email; user.userPic = "https://img.meituan.net/maoyanuser/8bcb755048586d97d25e8cbb91db389411430.png"; user.userPower = 'c'; user.userGender = '无'; db.userInfo.InsertOnSubmit(user); db.SubmitChanges(); return(true); } catch { return(false); } }
public userInfo Get_Scores() { userInfo temp = new userInfo(); temp.score = new List <int>(); temp.username = new List <string>(); string sql = "SELECT * FROM Users"; cmd = new MySqlCommand(sql, con); using (rdr = cmd.ExecuteReader()) { while (rdr.Read()) { // Debug.Log(rdr[1]+ " - " + rdr[3]); temp.score.Add(int.Parse(rdr[3].ToString())); temp.username.Add(rdr[1].ToString()); } } Debug.Log("time"); return(temp); }
public users CheckLogin(string check) { try { if (UName != string.Empty && PWord != string.Empty) { if (check == "admin") { using (SqlCommand cmd = new SqlCommand("CheckLogin")) { cmd.Parameters.Add("@para", SqlDbType.VarChar).Value = "CHECKADMIN"; cmd.Parameters.Add("@username", SqlDbType.VarChar).Value = UName; cmd.Parameters.Add("@password", SqlDbType.VarChar).Value = PWord; DataTable dTable = getData(cmd); if (dTable.Rows.Count > 0) { if (Convert.ToBoolean(dTable.Rows[0]["IS_USER"])) { aInfo = new AdminInfo(); aInfo.UserName = dTable.Rows[0]["user_name"].ToString(); ProfilePage = "~/admin/home.aspx"; return users.Admin; } else { return users.Anonymous; } } else { return users.Anonymous; } } } else { using (SqlCommand cmd = new SqlCommand("CheckLogin")) { cmd.Parameters.Add("@para", SqlDbType.VarChar).Value = "CHECKUSER"; cmd.Parameters.Add("@username", SqlDbType.VarChar).Value = UName; cmd.Parameters.Add("@password", SqlDbType.VarChar).Value = PWord; cmd.Parameters.Add("@online", SqlDbType.VarChar).Value = PWord; DataTable dTable = getData(cmd); if (dTable.Rows.Count > 0) { if (Convert.ToBoolean(dTable.Rows[0]["IS_USER"])) { uInfo = new userInfo(); uInfo.UserId = Convert.ToInt64(dTable.Rows[0]["user_id"]); string fName = dTable.Rows[0]["fname"].ToString(); string lName = dTable.Rows[0]["lname"].ToString(); uInfo.Email = dTable.Rows[0]["email"].ToString(); //if (fName == string.Empty) //{ // uInfo.UserName = string.Format("{0} {1}", fName, lName); //} //else //{ // uInfo.UserName = uInfo.UserName; //} uInfo.UserName = getUserName(fName, lName, uInfo.Email); uInfo.About = dTable.Rows[0]["about"].ToString(); ProfilePage = "~/home.aspx"; return users.User; } else { return users.Anonymous; } } else { return users.Anonymous; } } } } else { return users.Anonymous; } } catch (Exception ex) { return users.Anonymous; } }
/* * get users' information from the disk when server restart */ public bool getUserDataFromFile(String FileName) { try { using (StreamReader reader = new StreamReader(FileName)) { string line; while ((line = reader.ReadLine()) != null) { string[] words = line.Split(' '); string key = words[0]; double balance = Convert.ToDouble(words[1]); userInfo info = new userInfo(); info.cashBalance = balance; string line2; while((line2 = reader.ReadLine()) != "-----") { string[] stocksList = line2.Split(' '); info.StockShares.Add(stocksList[0], Convert.ToInt32(stocksList[1])); } this.UserDictionary.Add(key, info); } } } catch (Exception e) { Console.WriteLine(e.Message); return false; } return true; }
protected void setUsername() { uInfo = (userInfo)Session["_di09USR"]; ((Label)Master.FindControl("lblUserName")).Text = uInfo.UserName; }