public User Clone(User _user) { this.userID = _user.userID; this.level = _user.level; this.supermarket = _user.supermarket; return this; }
public bool Update(Model.User model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [users] set"); strSql.Append(" passwd=@Password"); strSql.Append(" where username=@UserName "); SqlParameter[] parameters = { new SqlParameter("@Password", SqlDbType.VarChar, 16), new SqlParameter("@UserName", SqlDbType.VarChar, 64) }; parameters[0].Value = model.Password; parameters[1].Value = model.UserName; int rows = SqlDbHelper.ExecuteNonQuery(strSql.ToString(), CommandType.Text, parameters); if (rows == 1) { return(true); } else { return(false); } }
public bool AddUser(Model.User user) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [users]"); strSql.Append("(username,passwd) values"); strSql.Append("(@UserName,@PassWord)"); SqlParameter[] parameters = { new SqlParameter("@UserName", SqlDbType.VarChar, 16), new SqlParameter("@PassWord", SqlDbType.VarChar, 64) }; parameters[0].Value = user.UserName; parameters[1].Value = user.Password; int row = SqlDbHelper.ExecuteNonQuery(strSql.ToString(), CommandType.Text, parameters); if (row == 0) { return(false); } else { return(true); } }
/// <summary> /// 无参构造函数 /// 内容初始化为测试模式 /// 需要参数的内容为null /// </summary> public frmPaymentTermial() { labelTitle.Text = frmSetting.paymentTitle; user = new User("pirat", -1, "-1") ; supermarket = null; InitializeComponent(); }
protected void RegisterUser_CreatedUser(object sender, EventArgs e) { #region ["Method FormsAutentication"] //FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */); //string continueUrl = RegisterUser.ContinueDestinationPageUrl; //if (String.IsNullOrEmpty(continueUrl)) //{ // continueUrl = "~/"; //} //Response.Redirect(continueUrl); #endregion string continueUrl = ""; Model.User _userM = new Model.User(); FAMIS_BLL.User _userB = new FAMIS_BLL.User(); _userM.Login = RegisterUser.UserName; _userM.Password = RegisterUser.Password; string sRet = _userB.Add(_userM); if (sRet == "") { continueUrl = "~/"; } Response.Redirect(continueUrl); }
protected void btn_Add_Click(object sender, EventArgs e) { if (txt_Name.Text.Trim().ToLower() == "admin") { UtilityService.Alert(this.Page,"admin是非法用户名,请换一个用户名称!"); return; } Model.User u = new Model.User(); u.UserID = txt_UM.Text.Trim(); u.UserName = txt_Name.Text.Trim(); //u.Password = txt_Pwd.Text.Trim(); u.Status = 1; u.OrganID = int.Parse(ddl_Organ.SelectedValue.ToString());//(int)Session["OrganID"]; u.OpenDate = DateTime.Parse(txt_OpenDate.Text); u.InputBy = Session["UserID"].ToString(); DataSet oldU = new UserBLL().GetList(" UserID = '" + u.UserID + "'"); if (oldU != null && oldU.Tables[0].Rows.Count > 0) { UtilityService.Alert(this, "该用户名已存在!"); return; } int re = new UserBLL().Add(u); if (re > 0) { UtilityService.AlertAndRedirect(this, "添加成功!", "UserMgr.aspx"); } else { UtilityService.Alert(this, "添加失败!"); } }
/// <summary> /// 检查是否重复 /// </summary> /// <param name="Model.User"></param> /// <returns></returns> public static bool CheckRepeatForEmail(Model.User model) { try { string sql = "select * from [User] where len(Email) > 0 and Email = @Email and Id <> @Id"; SqlParameter[] para = new SqlParameter[] { new SqlParameter("@Email", model.Email.Trim()), new SqlParameter("@Id", model.Id) }; DataTable temp = DBHelper.ExecuteGetDataTable(CommandType.Text, sql, para); if (temp.Rows.Count > 0) { return(true); } else { return(false); } } catch (Exception ex) { ErrorLog e = new ErrorLog(); e.TargetIds = model.Id.ToString(); e.CodeTag = "CheckRepeat"; e.LogName = "检查是否重复-ForUserEmail"; e.ErrorMsg = ex.Message.ToString(); ErrorLogService.AddErrorLog <Model.User>(e, model); return(true); } }
public List <Model.Participant> GetByConference(int confId) { List <Model.Participant> all = new List <Participant>(); foreach (ConferenceParticipant p in _context.ConferenceParticipants) { if (p.ConferenceId == confId) { User us = _context.Users.Find(p.UserId); Model.User user = new Model.User(us.UserId, us.Username, us.Password, us.Name, us.Affilliation, us.Email, us.canBePCMember, us.WebPage); Participant part = new Participant(user, confId, false, false, false, true); all.Add(part); } } foreach (PCMember p in _context.PCMembers) { if (p.ConferenceId == confId) { User us = _context.Users.Find(p.UserId); Model.User user = new Model.User(us.UserId, us.Username, us.Password, us.Name, us.Affilliation, us.Email, us.canBePCMember, us.WebPage); Participant part = new Participant(user, confId, p.isChair, p.isCoChair, true, false); all.Add(part); } } return(all); }
/// <summary> /// 无参构造基本窗体 /// </summary> public frmMain() { InitializeComponent(); user = new User("piratf", -1, "-1"); wn = null; wt = null; }
public static async Task <User> CheckUserRoleAsync(User user, Message message) { if (user.Role == Role.NotSet) { if (!message.Text.StartsWith(Emoji.Star)) { RequestUserRole(user, message.Chat.Id); } else if (message.Text.StartsWith(Emoji.Star)) { string msg = message.Text.Replace(Emoji.Star, ""); if (msg.Equals(Rm.GetString("Student"))) { UService.ChangeRole(user.Id, Role.Student); user = UService.View <Student>(user.Id); } else if (msg.Equals(Rm.GetString("Teacher"))) { UService.ChangeRole(user.Id, Role.Teacher); user = UService.View <Teacher>(user.Id); } await Bot.SendTextMessageAsync(message.Chat.Id, Rm.GetString("RoleSetMessage"), replyMarkup : new ReplyKeyboardHide()); } } return(user); }
/// <summary> /// Add a new entry to the DB /// </summary> /// <param name="message">Entry's message</param> /// <param name="user">User who created the new entry</param> public void AddEntry(string message, Model.User user) { Model.Entry currentEntry = new Model.Entry(); currentEntry.message = message; currentEntry.User = user; entryBusiness.AddEntry(currentEntry); if (entryBusiness.HasHashtags(message)) { List <Model.Hashtag> hashtags = new List <Model.Hashtag>(); hashtags = entryBusiness.GetHashtags(message); List <Model.Hashtag> newHashtags = new List <Model.Hashtag>(); List <Model.Entry_Hashtag> entry_hashtags = new List <Model.Entry_Hashtag>(); int lastId = hashtagBusiness.GetLastId() + 1; foreach (var hash in hashtags) { if (!(hashtagBusiness.Exists(hash.name))) { hash.ID = lastId; newHashtags.Add(hash); lastId++; } else { hash.ID = hashtagBusiness.GetHashtagIdByHashtagName(hash.name); } } hashtags.AddRange(hashtagBusiness.AddHashtag(newHashtags)); foreach (var hash in hashtags) { entryHashtagBusiness.AddEntryHashtag(currentEntry.ID, hash.ID); } } }
public List <Model.User> GetUsers() { List <Model.User> userList = new List <Model.User>(); SqlDataAdapter da = new SqlDataAdapter("select * from users where role='" + "user" + "'", con); DataSet userset = new DataSet(); da.Fill(userset, "Users"); for (int i = 0; i < userset.Tables["Users"].Rows.Count; i++) { Model.User u = new Model.User(); u.Uid = int.Parse(userset.Tables["Users"].Rows[i][0].ToString()); u.Uname = userset.Tables["Users"].Rows[i][1].ToString(); u.Uusername = null; u.Upassword = null; u.Uemail = userset.Tables["Users"].Rows[i][4].ToString(); u.Ugender = userset.Tables["Users"].Rows[i][5].ToString(); u.Umobile = userset.Tables["Users"].Rows[i][6].ToString(); u.Udate = Convert.ToDateTime(userset.Tables["Users"].Rows[i][7].ToString()); u.UDOB = Convert.ToDateTime(userset.Tables["Users"].Rows[i][8].ToString()); u.Urole = userset.Tables["Users"].Rows[i][9].ToString(); u.Uaddress = userset.Tables["Users"].Rows[i][10].ToString(); userList.Add(u); } return(userList); }
/// <summary> /// 获得数据列表 /// </summary> public List <Model.User> DataTableToList(DataTable dt) { List <Model.User> modelList = new List <Model.User>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Model.User model; for (int n = 0; n < rowsCount; n++) { model = new Model.User(); if (dt.Rows[n]["Id"].ToString() != "") { model.Id = int.Parse(dt.Rows[n]["Id"].ToString()); } model.LoginId = dt.Rows[n]["LoginId"].ToString(); model.LoginPwd = dt.Rows[n]["LoginPwd"].ToString(); model.Name = dt.Rows[n]["Name"].ToString(); model.Address = dt.Rows[n]["Address"].ToString(); model.Phone = dt.Rows[n]["Phone"].ToString(); model.Mail = dt.Rows[n]["Mail"].ToString(); if (dt.Rows[n]["UserStateId"].ToString() != "") { int UserStateId = int.Parse(dt.Rows[n]["UserStateId"].ToString()); model.UserState = userStateServices.GetModel(UserStateId); } modelList.Add(model); } } return(modelList); }
public async Task <User> CheckUserRoleAsync(User user, Message message) { if (user.Role == Role.NotSet) { if (!message.Text.StartsWith(Emoji.Star)) { RequestUserRole(user, message.Chat.Id); } else if (message.Text.StartsWith(Emoji.Star)) { string msg = message.Text.Replace(Emoji.Star, ""); if (msg.Equals(" Я учусь")) { NormalMessage($"User role changed:{user.Id}"); UService.ChangeRole(user.Id, Role.Student); user = UService.View <Student>(user.Id); } else if (msg.Equals(" Я преподаю")) { NormalMessage($"User role changed:{user.Id}"); UService.ChangeRole(user.Id, Role.Teacher); user = UService.View <Teacher>(user.Id); } await Bot.SendTextMessageAsync(message.Chat.Id, "Отлично, теперь я знаю кто ты!", replyMarkup : new ReplyKeyboardHide()); } } return(user); }
private void textBox1_Leave(object sender, EventArgs e) { if (this.textBox1.Text == null || this.textBox1.Text.Trim() == "") { MessageBox.Show("用戶名不能為空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.textBox1.Focus(); return; } Model.User userEntity = userBLL.queryByUsername(this.textBox1.Text.Trim()); if (userEntity != null) { List <RoleUnionUser> roleUnionUserList = roleRelUserService.queryRoleUionUserList(userEntity.Userid); if (roleUnionUserList != null) { this.comboBox1.DataSource = roleUnionUserList; this.comboBox1.DisplayMember = "Rolename"; this.comboBox1.ValueMember = "Roleno"; } else { MessageBox.Show("該用戶未分配角色,請聯繫管理員", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.textBox1.Focus(); return; } } else { MessageBox.Show("用戶名不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.textBox1.Focus(); return; } }
protected void ChangeUserInfo(object sender, EventArgs e) { string userName = Request.Form["name"]; string userPhone = Request.Form["phone"]; string userAge = Request.Form["age"]; string userSex = null; if (radio1.Checked) { userSex = "1"; } else { userSex = "0"; } string userID = Session["userID"].ToString(); Model.User user = new Model.User(); user.User_ID = userID; user.User_Name = userName; user.User_Phone = userPhone; user.User_Age = userAge; user.User_Sex = userSex; Session["username"] = userName; User.UpdateUserInfo(user); Response.Redirect("User_Center.aspx"); }
protected void Page_Load(object sender, EventArgs e) { string email = Request.QueryString["email"].ToString(); string activeCode = Request["activeCode"].ToString(); Model.User user = User.GetUserID(email); Session["email"] = email; Model.Enterprice enterprice = Enterprice.GetEnterpriceID(email); string password = enterprice.Enterprice_Password; if (user.User_ID != null) { if (User.ActiveUserAccount(email, activeCode)) { Response.Redirect("Reset_Password.aspx"); } } else if (enterprice.Enterprice_ID != null) { if (Enterprice.ActiveEnterpriceAccount(email, activeCode)) { Response.Redirect("Reset_Password.aspx"); } } }
public ActionResult SaveUser(User user) { user.CurrentCompany = CompanyManager.Get(user.CurrentCompany.CompanyID); UserManager.Save(user); return RedirectToAction("GetCompany", "Home", new { id = user.CurrentCompany.CompanyID }); }
public void Can_Add_User() { // Arrange .. create the user string displayName = "Galilyou"; string email = "*****@*****.**"; User user = new User(); user.DisplayName = displayName; user.Email = email; IUserRepository repository = _serviceLocator.Locate<IUserRepository>(); // act ... repository.Add(user); // now try to get the saved in user var tryToFindUser = repository.Filter( c => c.DisplayName == displayName, c => c.Email == email ); // assert Assert.Greater(tryToFindUser.Count(), 0); }
public int AddUserAndRetId(User user) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [users]"); strSql.Append("(username,passwd) output inserted.uid values"); strSql.Append("(@UserName,@PassWord)"); SqlParameter[] parameters = { new SqlParameter("@UserName",SqlDbType.VarChar,16), new SqlParameter("@PassWord",SqlDbType.VarChar,64) }; parameters[0].Value = user.UserName; parameters[1].Value = user.Password; SqlDataReader reader = SqlDbHelper.ExecuteReader(strSql.ToString(), CommandType.Text, parameters); try { if (reader.Read()) { return Int16.Parse(reader[0].ToString()); } } catch { return -1; } finally { reader.Close(); } return -1; }
private bool tryValidate(Model.User model, out string errMsg) { errMsg = ""; bool re = true; if ((model.Phone.Length == 0 && model.Email.Length == 0) || model.Phone.Length > 20 || model.Email.Length > 100 || model.Name == null || model.Name.Length == 0 || model.Name.Length > 20 || model.Signature.Length > 200 || model.Role <= 0) { errMsg = "输入数据不合法"; re = false; } if (re && UserManager.CheckRepeatForPhone(model)) { errMsg = "手机号不能重复"; re = false; } if (re && UserManager.CheckRepeatForEmail(model)) { errMsg = "邮箱不能重复"; re = false; } if (re && model.Modifier != auth.UserId) { errMsg = "登录信息异常,请刷新浏览器以重启应用(APP请退出应用后重新打开)"; re = false; } return(re); }
public Model.User queryUser(string username) { { Model.User user = null; StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT uuid,user_id,username,password,userdesc,department,prodline_id,op_user,create_time FROM t_user where username=@username"); MySqlParameter[] parameters = { new MySqlParameter("@username", MySqlDbType.VarChar, 900), }; parameters[0].Value = username; DataSet ds = SQLHelper.ExecuteDataset(SQLHelper.ConnectionString, CommandType.Text, strSql.ToString(), parameters); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { user = new Model.User(); user.Uuid = ds.Tables[0].Rows[0]["uuid"].ToString(); user.Userid = ds.Tables[0].Rows[0]["user_id"].ToString(); user.Username = ds.Tables[0].Rows[0]["username"].ToString(); user.Password = ds.Tables[0].Rows[0]["password"].ToString(); user.Userdesc = ds.Tables[0].Rows[0]["userdesc"].ToString(); user.Department = ds.Tables[0].Rows[0]["department"].ToString(); user.ProdLine = ds.Tables[0].Rows[0]["prodline_id"] == null ? null : ds.Tables[0].Rows[0]["prodline_id"].ToString(); user.Opuser = ds.Tables[0].Rows[0]["op_user"].ToString(); user.Createtime = ds.Tables[0].Rows[0]["create_time"].ToString(); } return(user); } }
public void LogIn(String username, String password, bool rememberme, string ReturnUrl) { // We should authenticate against a database table or something similar // but here, everything is ok as long as the // password and username are non-empty if (IsValid(username, password)) { CancelView(); // Ideally we would look up an user from the database // The domain model that represents the user // could implement IPrincipal or we could use an adapter User user = new User(username, new string[0]); Session["user"] = user; Redirect(ReturnUrl); } else { // If we got here then something is wrong // with the supplied username/password Flash["error"] = "Invalid user name or password. Try again."; RedirectToAction("Index", "ReturnUrl=" + ReturnUrl); } }
protected static void SeedDatabase(FluentModel context) { User usr1 = new User() { UserId = 1, Name = "Gary Adkins", Note = "note note note", Email = "*****@*****.**", Income = 10000.324m }; User usr2 = new User() { UserId = 2, Name = "Tim Gordon", Note = "note note note", Email = "*****@*****.**", Income = 10000.324m }; User usr3 = new User() { UserId = 3, Name = "Jack Jameson", Note = "note note note", Email = "*****@*****.**", Income = 10000.324m }; User usr4 = new User() { UserId = 4, Name = "Bill Tompson", Note = "note note note", Email = "*****@*****.**", Income = 10000.324m }; Group administratorsGroup = new Group() { GroupId = 1, Name = "Administrators", Description = "admin group description", }; administratorsGroup.UsersInGroup.Add(usr1); administratorsGroup.UsersInGroup.Add(usr2); Group coreUsersGroup = new Group() { GroupId = 2, Name = "Core users", Description = "core users description" }; coreUsersGroup.UsersInGroup.Add(usr3); coreUsersGroup.UsersInGroup.Add(usr4); context.Add(administratorsGroup); context.Add(coreUsersGroup); context.SaveChanges(); }
private void textBox2_Leave(object sender, EventArgs e) { if (this.textBox2.Text == null || this.textBox2.Text.Trim() == "") { return; } Model.User userEntity = userService.queryByUsername(this.textBox2.Text.Trim()); if (userEntity != null) { //查詢用戶實體內容 this.textBox3.Text = userEntity.Userid; this.textBox4.Text = userEntity.Userdesc; this.textBox5.Text = userEntity.Opuser; this.textBox6.Text = userEntity.Createtime; //查詢用戶對應的角色 displayList(userEntity.Userid); } else { this.clearAll(); this.textBox2.Focus(); return; } }
private static async Task CreateRootUser(IServiceProvider serviceProvider) { var options = serviceProvider.GetRequiredService <IOptions <ProductOptions> >().Value; var userManager = serviceProvider.GetRequiredService <UserManager <User> >(); var roleManager = serviceProvider.GetRequiredService <RoleManager <IdentityRole> >(); if (!await roleManager.RoleExistsAsync(ProductOptions.AUTH_ROOT_ROLE)) { await roleManager.CreateAsync(new IdentityRole(ProductOptions.AUTH_ROOT_ROLE)); } var rootUser = await userManager.FindByNameAsync(options.DefaultRootUser.UserName); if (rootUser == null) { rootUser = new Model.User { UserName = options.DefaultRootUser.UserName, FirstName = options.DefaultRootUser.FirstName, LastName = options.DefaultRootUser.LastName }; await userManager.CreateAsync(rootUser, options.DefaultRootUser.Password); await userManager.AddToRoleAsync(rootUser, ProductOptions.AUTH_ROOT_ROLE); await userManager.AddClaimAsync(rootUser, new Claim(ProductOptions.AUTH_ROOT_CLAIM, ProductOptions.AUTH_CLAIM_ALLOWED)); } }
/// <summary> /// 注册用户 /// </summary> /// <param name="email"></param> /// <param name="name"></param> /// <param name="password"></param> /// <returns></returns> public JsonBackResult RegisterUserInfo(string email, string name, string password, string code) { var usercode = Session["VerifyCode"].ToString(); var user = this._userService.GetList(s => s.EMail == email).FirstOrDefault(); if (user != null) { return(JsonBackResult(ResultStatus.EmailExist, "你输入的电子邮箱已经注册过")); } if (usercode != code) { return(JsonBackResult(ResultStatus.ValidateCodeErr, "验证码错误,请重新发送并输入新的验证码")); } Model.User realuser = new Model.User(); realuser.EMail = email; realuser.NickName = name; realuser.Password = EncryptionHelper.GetMd5Str(password); realuser.Count = +1; realuser.LoginTime = DateTime.Now; Role role1 = _roleService.GetList(s => s.Id == 1).FirstOrDefault(); realuser.Role = role1; realuser.RoleID = role1.Id; this._userService.Add(realuser); return(JsonBackResult(ResultStatus.Success)); }
/// <summary> /// User Authentication /// </summary> /// <param name="user">User to be validated</param> /// <returns>The user if login succeds</returns> public Model.User Login(Model.User user) { var userName = new SqlParameter("@User", user.userName); var pass = new SqlParameter("@Password", user.password); var query = _db.Users.SqlQuery("pub_ValidateUser @User, @Password", userName, pass); return(query.FirstOrDefault()); }
public void Connection_Connect_Behaviour_DisconnectUnconnectedUser() { User dummy = new User() { Name = "Crash Test Dummy", Password = "******" }; PieServiceClient pieService = new PieServiceClient(); pieService.Disconnect(dummy); //It's okay to disconnect a user even if he isn't connected }
public void Logout(Model.User u, IClient client) { if (loggedClients[u.Username] == null) { throw new NotImplementedException();//User is not logged in } loggedClients.Remove(u.Username); }
public User CreateNewUser(string username, string password, string email) { var author = new User {UserName = username, Password = password, Email = email}; _userRepository.SaveUser(author); var userRegistered = new UserRegisteredEventArgs(this, author); UserRegistered.Raise(userRegistered); return author; }
public static void AddWeblog(User model) { using (var db = DbBase.CreateDBContext()) { var list = db.GetCollection<User>("users"); list.Insert(model); } }
public ActionResult Index() { BPerson personBusiness = (BPerson)SimpleInjector.SimpleInjectorContainer.GetInstance <BPerson>(); BUser userBusiness = (BUser)SimpleInjector.SimpleInjectorContainer.GetInstance <BUser>(); Person personObj = personBusiness.SearchPerson(1); Model.User userObj = userBusiness.SearchUser(1); return(View()); }
public void Can_reset_password() { var author = new User {Email = "*****@*****.**", Password = "******"}; userRepository.Expect(x => x.GetAuthorByEmail("*****@*****.**")) .Return(author); membershipService.ResetPassword("*****@*****.**"); userRepository.AssertWasCalled(x => x.SaveUser(author)); Assert.AreNotEqual(author.Password, "1234"); }
/// <summary> /// 添加新用户 /// </summary> /// <param name="user">用户对象</param> /// <returns>添加操作结果</returns> //public int InsertUser(Model.User user) //{ //} /// <summary> /// 更新用户信息 /// </summary> /// <param name="ser">用户对象</param> /// <returns>结果</returns> public string UpdateUser(Model.User ser) { if (!string.IsNullOrEmpty(ser.pwd)) { ser.pwd = Encryption(ser.pwd); } return(Option(new DAL.UserDAL().UpdateUser(ser), "更新")); }
public void Logout(Model.User u, IClient client) { if (loggedClients.ContainsKey(u.Username)) { loggedClients.Remove(u.Username); return; } throw new ServerException("User not logged in");//User is not logged in }
public void Connection_Connect_Behaviour_ConnectTwice() { User dummy = new User() { Name = "Crash Test Dummy", Password = "******" }; PieServiceClient pieService = new PieServiceClient(); pieService.Connect(dummy); pieService.Connect(dummy); //It's okay for a user to connect twice }
public void GetUserListTest() { User user = new User(); var a = userService.GetUserList(user); foreach (var item in a) { Console.Write(item.UserName + "\n"); Console.Write(item.CreateTime + "\n"); } }
public void AddUserTest() { User user = new User(); user.UserName = "******"; user.Password = "******"; user.Gender = Gender.Man; user.CreateTime = DateTime.Now; userService.AddUser(user); }
public void TestGenerateConnectMessage() { User user = new User("TestUser"); String correctResult = "TCPConnectTo;TestUser;-1;;;127.0.0.1;12345"; Assert.AreEqual(correctResult, Message.GenerateConnectMessage(user, IPAddress.Parse("127.0.0.1"), 12345)); user = new User("TestUser"); correctResult = "TCPConnectTo;TestUser;-1;;;127.0.0.1;" + Configuration.DEFAULT_TCP_PORT; Assert.AreEqual(correctResult, Message.GenerateConnectMessage(user, IPAddress.Parse("127.0.0.1"), 51110)); }
public void TestGenerateTCPMessage() { User fromUser = new User("FromUser"); User toUser = new User("ToUser"); Message mess = new Message("This is the message"); mess.FromUser = fromUser; mess.ToUser = toUser; String correctResult = "TCPMessage;FromUser;-1;ToUser;-1;This is the message"; Assert.AreEqual(correctResult, Message.GenerateTCPMessage(mess)); }
public void TestIsNotifyMessage() { User user = new User("TestUser"); User user1 = new User("Second"); Assert.AreEqual(true, Message.IsNotifyMessage(Message.GenerateTCPNotify(new Message(user, user1, "Rename")))); Assert.AreEqual(false, Message.IsNotifyMessage(Message.GenerateTCPMessage(new Message(user, user1, "text")))); Assert.AreEqual(false, Message.IsNotifyMessage(Message.GenerateConnectMessage(user, IPAddress.Parse("127.0.0.1"), 12345))); Assert.AreEqual(true, Message.IsNotifyMessage("TCPNotify;a;1;;;102:192:192:192;12343")); Assert.AreEqual(false, Message.IsNotifyMessage("Test")); }
public ActionResult NewEntry(Model.Entry NewEntry) { if (Session["user"] != null) { Model.User user = (Model.User)Session["user"]; hashtagManager.AddEntry(NewEntry.message, user); return(RedirectToAction("Index", "Home")); } return(RedirectToAction("Index", "Login")); }
private string CompleteAuthorization(string verifier) { var response = this._consumer.ProcessUserAuthorization(this._requestToken, verifier); AccessToken = response.AccessToken; var extraData = response.ExtraData; var authenticatedUser = new User(extraData["fullname"], extraData["username"], extraData["user_nsid"]); Authenticated(this, new AuthenticatedEventArgs(authenticatedUser)); return response.AccessToken; }
/// <summary> /// Executes the default install. /// </summary> public void Execute() { if (isInitialized) { return; } var blog = blogRepository.GetBlog(); if (blog != null) { isInitialized = true; return; } var user = new User { UserName = "******", Password = "******", Email = "*****@*****.**", ID = 1 }; blog = new Blog { ID = 1, Title = "BlogSharp Blogs", Writers = new List<User> {user}, Founder = user, Configuration = new BlogConfiguration {PageSize = 10}, Host = "localhost", Name = "BlogSharp", }; var tag = new Tag {ID = 1, Name = "Welcome", FriendlyName = "welcome"}; var title = "Welcome to BlogSharp!"; var post = new Post { ID = 1, Blog = blog, Publisher = user, Tags = new List<Tag> {tag}, Title = title, Content = "Great blog post is here you are.", FriendlyTitle = generator.GenerateUrl("{0}", title), DateCreated = DateTime.Now, DatePublished = DateTime.Now }; tag.Posts.Add(post); blog.Configuration = new BlogConfiguration {PageSize = 10}; blog.Posts.Add(post); userRepository.SaveUser(user); blogRepository.SaveBlog(blog); postRepository.SavePost(post); isInitialized = true; }
public void saveUser(User user) { var existingUser = from u in forum.Users where u.id == user.id select u; if (existingUser.Any()) forum.Entry(user).State = System.Data.Entity.EntityState.Modified; else { forum.Users.Add(user); } forum.SaveChanges(); }
public ActionResult Login(Model.User currentUser) { Model.User user = hashtagManager.Login(currentUser); if (user != null) { currentUser = user; Session["user"] = currentUser; return(RedirectToAction("Index", "Home")); } return(RedirectToAction("Index", "Home")); }
public async Task <IActionResult> GetByLogin(string login) { Model.User entity = await dataAccess.FindByLoginAsync(login); if (entity == null) { return(NotFound()); } return(Ok(Mapper.Map <DTO.User>(entity))); }
public async Task <IActionResult> GetById(int id) { Model.User entity = await dataAccess.FindByIdAsync(id); if (entity == null) { return(NotFound()); } return(Ok(Mapper.Map <DTO.User>(entity))); }
public ActionResult Create(User u) { if (ModelState.IsValid) { bool added = _userLogic.AddUser(u); if(added) return RedirectToAction("Login"); ModelState.AddModelError("Username", "That user already exists"); } return View(); }
/// <summary> /// Updates a user. /// </summary> /// <param name="user"></param> /// <returns>Returns the new rowversion of the user.</returns> public byte[] UpdateUser(User user) { ThrowIfNull(user); user.AuthUser = null; user.Address = null; ValidateAndThrow(user, _userValidator); Context.Users.Attach(user); //Context.SetEntityState(user, EntityState.Modified); Context.SaveChanges(); return(user.Version); }
/// <summary> /// 添加用户 /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool AddUser(ref Model.User model, out string errMsg) { errMsg = ""; try { model.Name = model.Name.Trim(); model.Phone = model.Phone.Trim(); model.Email = model.Email.Trim(); model.Signature = model.Signature.Trim(); SqlParameter[] para = new SqlParameter[] { new SqlParameter("@Name", model.Name), new SqlParameter("@Phone", model.Phone), new SqlParameter("@Email", model.Email), new SqlParameter("@Role", model.Role), new SqlParameter("@Signature", model.Signature), new SqlParameter("@IsSignNeeded", model.IsSignNeeded), new SqlParameter("@Creater", model.Creater), new SqlParameter("@CreatedDate", model.CreatedDate), new SqlParameter("@Modifier", model.Modifier), new SqlParameter("@ModifiedDate", model.ModifiedDate), new SqlParameter("@return", SqlDbType.Int) }; para[10].Direction = ParameterDirection.ReturnValue; int i = DBHelper.ExecuteNonQuery(CommandType.StoredProcedure, "proc_UserInsert", para); if (i > 0) { model.Id = int.Parse(para[10].Value.ToString()); EventLog e = new EventLog(); e.TargetIds = para[10].Value.ToString(); e.CodeTag = "AddUser"; e.LogName = "添加用户"; EventLogService.AddEventLog <Model.User>(e, model); return(true); } else { errMsg = "添加记录失败,受影响行数为0"; return(false); } } catch (Exception ex) { errMsg = ex.Message; ErrorLog e = new ErrorLog(); e.TargetIds = "0"; e.CodeTag = "AddUser"; e.LogName = "添加用户"; e.ErrorMsg = ex.Message.ToString(); ErrorLogService.AddErrorLog <Model.User>(e, model); return(false); } }
public void ContractInsertWithIdentity([IncludeDataContexts(ProviderName.Oracle)] string context) { using (var db = GetDataContext(context)) { db.BeginTransaction(); var user = new User { Name = "user" }; user.Id = Convert.ToInt64(db.InsertWithIdentity(user)); db.InsertWithIdentity(new Contract { UserId = user.Id, ContractNo = 1, Name = "contract" }); } }
private void SendInitialUserEmail(User user, bool needsResetKey) { if (needsResetKey) { _authService.SetResetKey(user.AuthUser, 1440); _authService.SendNewUserResetEmail(user.AuthUser, user.Email); } else { _authService.SendNewUserInitEmail(user.AuthUser, user.Email); } }
public void Index() { var user = new User { EmailAddress = "*****@*****.**", Name = "admin", Password = new Password("toeter") }; CurrentSession.Save(user); Redirect("home", "index"); }
public void ContractLinqInsertWithIdentity(string context) { using (var db = GetDataContext(context)) { db.BeginTransaction(); var user = new User { Name = "user" }; user.Id = Convert.ToInt64(db.InsertWithIdentity(user)); db.GetTable<Contract>().InsertWithIdentity(() => new Contract { UserId = user.Id, ContractNo = 1, Name = "contract" }); } }
public User GetUserID(string email) { OxcoderIFactory.IFactory factory = new OxcoderFactory.SqlSeverFactory(); OxcoderIDAL.UserIDAL dalad = factory.getUserInstance(); SqlDataReader dr = dalad.GetUserID(email); Model.User user = new Model.User(); if (dr.Read()) { user.User_ID = dr["User_ID"].ToString(); user.User_Name = dr["User_Name"].ToString(); } return user; }
private void ApplyUser(User user) { if (this._preferences != null) { if (this._preferences.CheckForUpdates) { var update = this._updateCheckLogic.UpdateAvailable(this._preferences); if (update.Available) { this._view.ShowUpdateAvailableNotification(update.LatestVersion); } } } this._view.ShowLoggedInControl(this._preferences); this._view.User = user; this._view.ShowSpinner(false); }
public ActionResult AddUser(int? id) { //var curUser = Session["CurrentUser"] as UserLoginModel; //string userName = curUser.UserName; ViewData["RoleList"] = powerSv.GetAllRole(); User User = new User(); if (id != null) { User = powerSv.GetUser(id.Value); } return PartialView(User); }
public async Task <IActionResult> Delete(int id) { Model.User entity = await dataAccess.FindByIdAsync(id); if (entity == null) { return(NotFound()); } await dataAccess.DeleteAsync(entity); return(Accepted(Mapper.Map <DTO.User>(entity))); }