//getting the list of all the email already having an account in the service public static List <Model.UserModel> EmailChecker() { try { string connstr = GetMysqlConnectionString(); string sql = $"SELECT Email FROM user"; List <Model.UserModel> EmailList = new List <Model.UserModel>(); using (MySqlConnection conn = new MySqlConnection(connstr)) { conn.Open(); using (MySqlCommand cmd = new MySqlCommand(sql, conn)) { using (MySqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { Model.UserModel u = new Model.UserModel(); u.Email = reader.GetString(0); EmailList.Add(u); } return(EmailList); } } } } catch { throw; } }
}//constructor /// <summary> /// This method returns TRUE if the following hold: /// username exists in the user table /// password matches with the value in the user table /// </summary> /// <param name="email"></param> /// <param name="password"></param> /// <returns></returns> public Boolean validateUser(String email, String password) { if ((email.Equals(null)) || (password.Equals(null))) { return(false); } Model.UserModel user = new Model.UserModel(); DBManager.UserM uu = new DBManager.UserM(); user = uu.getUserRecord(connection, email); //Email validatation imposed on client side //if user doesn't exist, false if (user == null) { return(false); } //return true if crediential matches if ((user.getPassword()).Equals(password)) { Console.WriteLine("Match Found!"); return(true); } Console.WriteLine("invalid creds"); return(false); }
//inserts a new user into the mysql database public void AddUserToMysql(Model.UserModel u) { string firstname = u.FirstName; string lastname = u.LastName; string email = u.Email; string phone = u.phone; string pass = u.Password; string path = u.PhotoPath; try { string connstr = GetMysqlConnectionString(); string sql = $"INSERT INTO user (Name,LastName,Email,Phone,Password,PhotoPath) VALUES ('{firstname}', '{lastname}', '{email}', '{phone}',MD5('{pass}'), '{path}')"; using (MySqlConnection conn = new MySqlConnection(connstr)) { conn.Open(); MySqlCommand cmd = new MySqlCommand(sql, conn); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); conn.Close(); } } catch { throw; } }
public UserModel MyInformation(int myId) { UserModel newUser; List<Model.UserModel> users = new List<Model.UserModel>(); using (HttpClient http = new HttpClient()) { var url = String.Format("http://localhost:50842/User/{0}/me", myId); http.DefaultRequestHeaders.Accept.Add( new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); var response = http.GetAsync(url).Result; var result = response.Content.ReadAsStringAsync().Result; JObject friend = JObject.Parse(result.ToString()); newUser = new Model.UserModel(); newUser.Name = friend["us_name"].ToString(); newUser.Age = int.Parse(friend["us_age"].ToString()); newUser.Bio = friend["us_Bio"].ToString(); newUser.Avatar = new BitmapImage(new Uri("ms-appx:///Assets/avatar.png", UriKind.RelativeOrAbsolute)); newUser.Points = new List<Model.UserModel.UserPoint>(); string pontoString; foreach (JObject location in friend["Location"].Children()) { pontoString = location["Point"]["Geography"]["WellKnownText"].ToString().Substring(7).Replace(')', ' ').Trim(); newUser.Points.Add(new Model.UserModel.UserPoint { Latitude = float.Parse(pontoString.Split(' ')[0]), Longitude = float.Parse(pontoString.Split(' ')[1]) }); } return newUser; } }
// Get data public void getData(Model.UserModel user) { string[] users = System.IO.File.ReadAllLines("D:\\Data\\SourceTree\\Train\\Week_1\\Project_Week_1\\Project_Week_1\\DB\\DB.txt"); foreach (var currentUser in users) { } }
public UserModel MyInformation(int myId) { UserModel newUser; List <Model.UserModel> users = new List <Model.UserModel>(); using (HttpClient http = new HttpClient()) { var url = String.Format("http://localhost:50842/User/{0}/me", myId); http.DefaultRequestHeaders.Accept.Add( new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); var response = http.GetAsync(url).Result; var result = response.Content.ReadAsStringAsync().Result; JObject friend = JObject.Parse(result.ToString()); newUser = new Model.UserModel(); newUser.Name = friend["us_name"].ToString(); newUser.Age = int.Parse(friend["us_age"].ToString()); newUser.Bio = friend["us_Bio"].ToString(); newUser.Avatar = new BitmapImage(new Uri("ms-appx:///Assets/avatar.png", UriKind.RelativeOrAbsolute)); newUser.Points = new List <Model.UserModel.UserPoint>(); string pontoString; foreach (JObject location in friend["Location"].Children()) { pontoString = location["Point"]["Geography"]["WellKnownText"].ToString().Substring(7).Replace(')', ' ').Trim(); newUser.Points.Add(new Model.UserModel.UserPoint { Latitude = float.Parse(pontoString.Split(' ')[0]), Longitude = float.Parse(pontoString.Split(' ')[1]) }); } return(newUser); } }
public UsersViewModel(Model.UserModel userModel) { _userModel = userModel; Initialize(); RefreshAction(); }
/// <summary> /// 注册 /// </summary> /// <param name="email"></param> /// <param name="code"></param> /// <returns></returns> public JsonBackResult RegisterUserData(string email, string password, string password1, string code) { var usercode = Session["RegisterVerifyCode"].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.UserModel userData = new Model.UserModel(); userData.EMail = email; userData.NickName = "小明"; userData.Count = 0; userData.HeadPicUrl = "../Imgs/"; userData.LoginTime = DateTime.Now.ToString(); userData.BuildTime = DateTime.Now.ToString(); userData.Pwd = EncryptionHelper.GetMd5Str(password); userData.Status = 1; userData.TelNumber = "18251935177"; userData.UName = "小明"; this._userService.Add(userData); return(JsonBackResult(ResultStatus.Success)); }
/// <summary> /// 根据用户名返回一个实体 /// </summary> public Model.UserModel GetModel(string user_name) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id from " + databaseprefix + "User"); strSql.Append(" where UserName=@UserName and islock=0"); SqlParameter[] parameters = { new SqlParameter("@UserName", SqlDbType.NVarChar, 100), }; parameters[0].Value = user_name; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj != null) { int id = Convert.ToInt32(obj); Model.UserModel model = GetModel(id); //账户工程信息 model.Projects = new UserProjectDal(databaseprefix).GetList(model.UserName); return(model); } return(null); }
/// <summary> /// 转化为model /// </summary> /// <param name="item"></param> /// <returns></returns> private Model.UserModel GetModelByDataRow(DataRow item) { Model.UserModel model = new Model.UserModel(); if (item["id"].ToString() != "") { model.ID = int.Parse(item["id"].ToString()); } if (item["RoleId"].ToString() != "") { model.RoleId = int.Parse(item["RoleId"].ToString()); } if (item["RoleType"].ToString() != "") { model.RoleType = int.Parse(item["RoleType"].ToString()); } model.RoleName = item["RoleName"].ToString(); model.UserName = item["UserName"].ToString(); model.Password = item["Password"].ToString(); model.RealName = item["RealName"].ToString(); model.Email = item["Email"].ToString(); model.Tel = item["Tel"].ToString(); model.IsLock = int.Parse(item["IsLock"].ToString()); model.ClientIp = item["ClientIp"].ToString(); if (item["ClientPath"].ToString() != "") { model.ClientPath = item["ClientPath"].ToString(); } if (item["AddTime"].ToString() != "") { model.AddTime = DateTime.Parse(item["AddTime"].ToString()); } return(model); }
public async Task UpdateUser(Model.UserModel model) { await DeleteAsync(model).ContinueWith(async(response) => { await InsertAsync(model); }); }
/// <summary> /// 初始化账号信息 /// </summary> /// <param name="userName"></param> /// <param name="password">如果没有密码,为空即可</param> /// <returns></returns> public static Model.UserModel GetUserInfo(string userName, string password) { //if (SystemBll._userInfo == null) //{ //判断登陆方式 switch (ServerConfigInfo.SystemLoginType) { case 0: _userInfo = new ManagerBll().GetModel(userName, password); break; case 1: _userInfo = new ManagerBll().GetModel(userName); break; case 2: throw new CustomException("暂时不支持域账号,请联系管理员处理!"); default: break; } //} return(_userInfo); }
/// <summary> /// 异步记录用户操作日志 /// </summary> /// <param name="projectId"></param> /// <param name="projectName"></param> /// <param name="clientPath"></param> /// <param name="action"></param> public static void ActionLogAsyn(int projectId, string projectName, string clientPath, ActionType action) { ActionLogHandler handler = new ActionLogHandler(ActionLog); Model.UserModel user = Bll.SystemBll.UserInfo; handler.BeginInvoke(projectId, projectName, clientPath, action, IAsyncMenthod, null); }
public MainViewModel() { UserInfo = new Model.UserModel(); this.NavChangedCommand = new CommandBase(); this.NavChangedCommand.DoExcute = new Action <object>(DoNavChanged); this.NavChangedCommand.DoCanExcute = new Func <object, bool>((o) => true); DoNavChanged("FirstPageView"); //直接打开首页 }
// Change position of a swimlane /********************************************/ // Fetch data protected async Task FetchData() { string username = Context.User.Identity.Name; Task <Model.UserModel> task1 = Task.Run(() => myUA.getUserData(username)); Task task2 = Task.Run(() => GetChannelID()); sender = await task1; await task2; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.UserModel GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from " + databaseprefix + "User "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Model.UserModel model = new Model.UserModel(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { //RoleId,RoleType,RoleName,UserName,Password,RealName,Email,Tel,IsLock,ClientIp,ClientPath,AddTime if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.ID = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["RoleId"].ToString() != "") { model.RoleId = int.Parse(ds.Tables[0].Rows[0]["RoleId"].ToString()); } if (ds.Tables[0].Rows[0]["RoleType"].ToString() != "") { model.RoleType = int.Parse(ds.Tables[0].Rows[0]["RoleType"].ToString()); } model.RoleName = ds.Tables[0].Rows[0]["RoleName"].ToString(); model.UserName = ds.Tables[0].Rows[0]["UserName"].ToString(); model.Password = ds.Tables[0].Rows[0]["Password"].ToString(); model.RealName = ds.Tables[0].Rows[0]["RealName"].ToString(); model.Email = ds.Tables[0].Rows[0]["Email"].ToString(); model.Tel = ds.Tables[0].Rows[0]["Tel"].ToString(); model.IsLock = int.Parse(ds.Tables[0].Rows[0]["IsLock"].ToString()); model.ClientIp = ds.Tables[0].Rows[0]["ClientIp"].ToString(); if (ds.Tables[0].Rows[0]["ClientPath"].ToString() != "") { model.ClientPath = ds.Tables[0].Rows[0]["ClientPath"].ToString(); } if (ds.Tables[0].Rows[0]["AddTime"].ToString() != "") { model.AddTime = DateTime.Parse(ds.Tables[0].Rows[0]["AddTime"].ToString()); } //账户工程信息 model.Projects = new UserProjectDal(databaseprefix).GetList(model.UserName); return(model); } else { return(null); } }
private void InitializeData(Model.UserModel d) { this.d = d; TextBox_用户名.IsReadOnly = true; TextBox_用户名.Text = d.Username; TextBox_用户密码.Password = d.Password; TextBox_真实姓名.Text = d.Realname; ComboBox_用户权限.SelectedValue = d.Permissions; TextBox_Remark.Text = d.Remark; }
// Fetch list of user will receive the message and data protected async Task FetchUserData(int projectID) { string username = Context.User.Identity.Name; Task <Model.UserModel> task1 = Task.Run(() => myUA.getUserData(username)); Task <List <int> > task2 = Task.Run(() => myPA.getProjectMemberID(projectID)); sender = await task1; ids = (await task2).ConvertAll(x => x.ToString()); }
/// <summary> /// This method findUserId method returns id of given username /// </summary> /// <param name="username"></param> /// <returns></returns> public int findUserId(string username) { DBManager.UserM u = new DBManager.UserM(); Model.UserModel user = u.getUserRecord(connection, username); if (user == null) { return(-1); } return(user.getUid()); }
public ReadUserPage(Model.UserModel user) { InitializeComponent(); this.BindingContext = new ViewModel.UserViewModel(user); MaxEntry.TextChanged += OnTextChanged; EntryUsername.Completed += (s, e) => EntryIntegrationId.Focus(); EntryIntegrationId.Completed += (s, e) => MaxEntry.Focus(); }
public UserViewModel(Model.UserModel model) { _appUserRepository = DependencyService.Get <IAppUserRepository>(); _navigationService = DependencyService.Get <INavigationService>(); _messageService = DependencyService.Get <IMessageService>(); _apiService = DependencyService.Get <IApiService>(); this.IdUser = model.IdUser; this.Username = model.Username; this.IntegrationId = model.IntegrationId; this.MaxLancamentoDia = model.MaxLancamentoDia; }
// Get Sender public async Task FetchData(int commentID) { myUA = new UserAccess(); myCA = new CommentAccess(); string username = Context.User.Identity.Name; Task <Model.UserModel> task1 = Task.Run(() => myUA.getUserData(username)); Task <Model.CommentModel> task2 = Task.Run(() => myCA.getComment(commentID)); sender = await task1; comment = await task2; projectID = comment.Project_ID; }
public StartViewModel(Model.UserModel userModel) { _userModel = userModel; ErrorText = String.Empty; ContinueCommand = new Misc.Command(ContinueAction); _userModel.Update(); if (!_userModel.Items.Any()) { CreateDefaultUser(); } }
/// <summary> /// 自动登陆 /// </summary> public static void AutoLogin() { //获取系统账号 Model.UserModel user = GetUserInfo(currentUserName, string.Empty); if (user == null || string.IsNullOrEmpty(user.UserName) || string.IsNullOrEmpty(user.RealName)) { throw new CustomException(string.Format("该账号:{0},没有权限,请联系管理员处理!", SystemBll.currentUserName) + ManagerLinkInfo); } if (user.IsLock == 1) { throw new CustomException(string.Format("该账号:{0},已经被锁定 ,请联系管理员处理!", SystemBll.currentUserName) + ManagerLinkInfo); } }
// Announce to all member about the deleted project public void DeleteProject(int projectID, string projectName, int userID) { string username = Context.User.Identity.Name; sender = myUA.getUserData(username); DiposeConnection(); if (sender.User_ID == userID) { // Message for notification center Clients.Others.msgProject(sender, "deleted", projectID, projectName); // Deleted project object for other user Clients.Others.deleteProject(projectID); } }
private void buttonLogin_Click(object sender, EventArgs e) { BLLUsers.UserManagerServiceClient client = WCFServiceBLL.GetUserService(); Model.UserModel userModel = client.Login(textBoxUserName.Text, textBoxPassword.Text); if (userModel != null) { AppParams.CurrentUser = userModel; this.LogType = 1; this.Hide(); } else { MessageBox.Show("登录失败,确认帐号密码是否正确"); } }
public IEnumerable<Model.UserModel> FindFriends(double latitude, double longitude, int distance, int myId) { try { List<Model.UserModel> users = new List<Model.UserModel>(); using (HttpClient http = new HttpClient()) { var url = String.Format("http://localhost:50842/api/friends/{0}/{1}/{2}/{3}/", latitude, longitude, distance, myId); http.DefaultRequestHeaders.Accept.Add( new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); var response = http.GetAsync(url).Result; var result = response.Content.ReadAsStringAsync().Result; JArray friends = JArray.Parse(result.ToString()); foreach (JObject friend in friends.Children()) { Model.UserModel newUser = new Model.UserModel(); newUser.Name = friend["us_name"].ToString(); newUser.Age = int.Parse(friend["us_age"].ToString()); newUser.Bio = friend["us_Bio"].ToString(); newUser.Avatar = new BitmapImage(new Uri("ms-appx:///Assets/avatar_Laize.jpg", UriKind.RelativeOrAbsolute)); newUser.Points = new List<Model.UserModel.UserPoint>(); string pontoString; foreach (JObject location in friend["Location"].Children()) { pontoString = location["Point"]["Geography"]["WellKnownText"].ToString().Substring(7).Replace(')', ' ').Trim(); newUser.Points.Add(new Model.UserModel.UserPoint { Latitude = float.Parse(pontoString.Split(' ')[0]), Longitude = float.Parse(pontoString.Split(' ')[1]) }); } users.Add(newUser); } } return users; } // serialize JSON results into .NET objects catch (Exception e) { throw; } return null; }
public IEnumerable <Model.UserModel> FindFriends(double latitude, double longitude, int distance, int myId) { try { List <Model.UserModel> users = new List <Model.UserModel>(); using (HttpClient http = new HttpClient()) { var url = String.Format("http://localhost:50842/api/friends/{0}/{1}/{2}/{3}/", latitude, longitude, distance, myId); http.DefaultRequestHeaders.Accept.Add( new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); var response = http.GetAsync(url).Result; var result = response.Content.ReadAsStringAsync().Result; JArray friends = JArray.Parse(result.ToString()); foreach (JObject friend in friends.Children()) { Model.UserModel newUser = new Model.UserModel(); newUser.Name = friend["us_name"].ToString(); newUser.Age = int.Parse(friend["us_age"].ToString()); newUser.Bio = friend["us_Bio"].ToString(); newUser.Avatar = new BitmapImage(new Uri("ms-appx:///Assets/avatar_Laize.jpg", UriKind.RelativeOrAbsolute)); newUser.Points = new List <Model.UserModel.UserPoint>(); string pontoString; foreach (JObject location in friend["Location"].Children()) { pontoString = location["Point"]["Geography"]["WellKnownText"].ToString().Substring(7).Replace(')', ' ').Trim(); newUser.Points.Add(new Model.UserModel.UserPoint { Latitude = float.Parse(pontoString.Split(' ')[0]), Longitude = float.Parse(pontoString.Split(' ')[1]) }); } users.Add(newUser); } } return(users); } // serialize JSON results into .NET objects catch (Exception e) { throw; } return(null); }
public string AddUser(string strUserName, int RoleId) { Model.UserModel mod = new Model.UserModel(); mod.LoginName = strUserName; mod.RoleId = RoleId; mod.Pwd = "666666"; //初始密码为666666 BLL.UserBLL bll = new BLL.UserBLL(); bool b = bll.Add(mod); if (b) { return("添加用户成功".ToJson()); } else { return("添加用户失败".ToJson()); } }
/// ///METHOD TO HANDLE THE REGISTRATION /// public void HandleAccountRegistration() { model = prepareRegistrationData.FormatInformation(model); model.Password = hashpassword.HashPassword(model.Password); int numberRows = accountServices.GetUserByPhone(model.Phone).Rows.Count; if (numberRows == 0) { // MessageBox.Show(, "Account Registration", MessageBoxButtons.OK, MessageBoxIcon.Information); RegisterNotificationlbl.Text = accountServices.AddUser(model).ToString(); RegisterNotificationlbl.ForeColor = Color.Green; } else { RegisterNotificationlbl.Text = "Phone Number already Registered"; RegisterNotificationlbl.ForeColor = Color.Red; } }
public virtual List <int> Register(Model.UserModel user) { //如果有查询就放到外层 //... using (IUnitOfWork tran = EdsUtilOfWorkFactory.GetUnitOfWorkOfEDS()) { //实现调用DAO层方法 //... ChangeWorkStatusPM pmModel = new ChangeWorkStatusPM(); pmModel.Id = 1; pmModel.WorkStatus = 1; dao.ChangeWorkStatusToSql(pmModel); tran.Complete(); } //new UserDao().RegisterToSql(new Model.UserModel()); return(new List <int>() { 1, 2 }); }
// When a member add new user to the project public async Task AddUser(int projectID, int addedMember) { await FetchUserData(projectID); Model.UserModel target = myUA.getUserData(addedMember); Task <string> task1 = Task.Run(() => myUA.getPersonContainer <Model.UserModel>(target, true, projectID)); // Get project data Task <Model.ProjectModel> task2 = Task.Run(() => myPA.getProjectData(projectID)); // Get owner data if the sender is not owner var project = await task2; string personContainer = await task1; // Message for notification center Task task3 = Task.Run(() => Clients.Users(ids).msgAddUser(sender, target, project.Name)); // Person Object for display in other member display Task task4 = Task.Run(() => Clients.Users(ids).addUser(projectID, personContainer)); // Project object for the added person Clients.User(addedMember.ToString()).addProject(project); // Owner object for the added person Model.UserModel owner; if (sender.User_ID != project.Owner) { owner = myUA.getUserData(project.Owner); } else { owner = sender; } Clients.User(addedMember.ToString()).addOwner(owner); DiposeConnection(); await Task.WhenAll(task3, task4); }