public UserInfo GetUserInfo(UserObj userLogin) { string sql = "select A.*,B.*,C.ClientAlias from Dol_User A inner join User_Role B on A.RoleId=B.RoleId inner join Dol_Client C on C.ClientId=A.ClientId where A.UserName=@0 and A.IsDelete='false' "; var _actual = _db.FirstOrDefault <UserInfo>(sql, userLogin.Username); return(_actual); }
public void SetUserCache(UserObj userObj) { if (userObj != null) { this.Cache.Set(UserObjCacheKey, userObj, TimeSpan.FromHours(1)); } }
public BindCourse(UserObj user, string classId, Guid dsId, Guid taskId) { this.user = user; this.classId = classId; this.dsId = dsId; this.taskId = taskId; }
public static UserObj MagicMapper(this TblUser item) { if (item == null) { return(null); } //List<RoleObj> listRoles; //foreach (var x in item.TblRoles) //{ // listRoles.Add //} UserObj obj = new UserObj { UserId = item.UserId, Firstname = item.Firstname, Lastname = item.Lastname, Phone = item.Phone, Fax = item.Fax, Username = item.Username, EmailSmtp = item.EmailSmtp, Active = item.Active }; //obj.TblRoles = item.TblRoles. return(obj); }
public UserObj GetUserByUserName(string userName) { using (helper = new SqlHelper()) { helper.AddStringParameter("@UserName", 50, userName); using (SqlDataReader dr = helper.ExecuteReader("select UserID,UserName,RegDate,LastLoginTime,NickName,Gender,Email,BirthDay,Password,Points from Users where UserName=@UserName", CommandType.Text)) { if (dr.HasRows && dr.Read()) { UserObj user = new UserObj(); user.UserID = (int)dr[0]; user.UserName = dr[1] == DBNull.Value ? null : (string)dr[1]; user.RegDate = dr[2] == DBNull.Value ? DateTime.MinValue : (DateTime)dr[2]; user.LastLoginTime = dr[3] == DBNull.Value ? DateTime.MinValue : (DateTime)dr[3]; user.NickName = dr[4] == DBNull.Value ? null : (string)dr[4]; user.Gender = dr[5] == DBNull.Value ? false : (bool)dr[5]; user.Email = dr[6] == DBNull.Value ? null : (string)dr[6]; user.BirthDay = dr[7] == DBNull.Value ? DateTime.MinValue : (DateTime)dr[7]; user.Password = dr[8] == DBNull.Value ? null : (string)dr[8]; user.Points = dr[9] == DBNull.Value ? 0 : (int)dr[9]; return(user); } return(null); } } }
public ActionResult AddMessage() { string sessionCheckCode = Session["CheckCode"] == null ? null : Session["CheckCode"].ToString(); Session["CheckCode"] = null; if (sessionCheckCode == null) { return(Json(new { success = false, msg = "验证码已经过期,请刷新验证码!" })); } Validation vld = new Validation(); string checkCode = vld.Get("checkCode"); if (checkCode.ToLower() != sessionCheckCode.ToLower()) { return(Json(new { success = false, msg = "验证码错误!" })); } int productID = vld.GetInt("productID"); string content = vld.Get("content"); bool isAnonymity = vld.GetBool("isAnonymity"); UserObj user = AppData.SessionUser; ProductBLL productBLL = new ProductBLL(); productBLL.AddMessage(user == null ? Request.UserHostAddress : user.UserName, productID, content, isAnonymity); return(Json(new { success = true })); }
public UserDetails Register(UserObj id) { UserManager userManager = new UserManager(); return(userManager.RegisterUser(id)); }
public IEnumerable <UserActivity> GetBizForCustmer(UserObj id) { UserManager userManager = new UserManager(); return(userManager.GetBizForCustmer(id)); }
/// <summary> public void searchForAccount(UserObj obj, string AccId, string name, string type, string balance, string status) { List <UserObj> lst = new List <UserObj>(); for (int i = 0; i < list.Count; i++) { if ((AccId.Equals("") ? true : list[i].UserID == obj.UserID) && (balance.Equals("") ? true : list[i].cash == obj.cash) && (name.Equals("") ? true : list[i].ID.Equals(obj.ID)) && (type.Equals("") ? true : list[i].type.Equals(obj.type)) && (status.Equals("") ? true : list[i].status.Equals(obj.status))) { lst.Add(list[i]); } } Console.WriteLine("SEARCH MENU:\n"); foreach (UserObj o in lst) { string s = string.Format( "\nAccount ID User ID Holders Name Type Balance Status\n {0,-10} {1,-10} {2,-15} {3,-10} {4,-8} {5,-10} ", o.UserID, o.ID, o.name, o.type, o.cash, o.status ); Console.WriteLine(s); } }
public async Task <IActionResult> PutUserObj(string id, UserObj userObj) { if (id != userObj.id) { return(BadRequest()); } _context.Entry(userObj).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserObjExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
IEnumerator SceneBuilder() { SceneService sceneSrv = GameContext.sceneSrv; sceneSrv.CreateSceneObj(cfgScene); _SetLoadPercent(5); yield return(new WaitForSeconds(1)); sceneSrv.LoadMapRes(); _SetLoadPercent(20); yield return(new WaitForSeconds(1)); sceneSrv.LoadMapInfo(); _SetLoadPercent(50); yield return(new WaitForSeconds(1)); UserObj user = null; sceneSrv.AddUserSelf(user); UserObj userOther = null; sceneSrv.AddUserOther(userOther); NpcObj npc = null; sceneSrv.AddNpcObj(npc); _SetLoadPercent(80); yield return(new WaitForSeconds(1)); sceneSrv.LoadStory(); sceneSrv.LoadUI(); _SetLoadPercent(100); yield return(new WaitForSeconds(1)); }
public async Task register(params string[] args /*string waifu, string gender, string waifugender*/) { if (args.Count() < 3) { await ReplyAsync("Incorrect syntax. Command format: !register [waifu] [your gender (M/F)] [waifu/husbando gender (M/F)]"); return; } string waifu = args[0]; string gender = args[1]; string waifugender = args[2]; if (gender != "M" && gender != "F" || waifugender != "M" && waifugender != "F") { await ReplyAsync("Incorrect syntax. Command format: !register [waifu] [your gender (M/F)] [waifu/husbando gender (M/F)]"); return; } UserObj send = new UserObj(); send.DiscordId = Convert.ToInt64(Context.User.Id); send.Waifu = waifu; send.Gender = gender; send.WaifuGender = waifugender; await ReplyAsync(waifuReg.Register(send)); }
public bool Login(UserObj user) { using (helper = new SqlHelper()) { helper.AddStringParameter("@UserName", 20, user.UserName); helper.AddStringParameter("@Password", 128, user.Password); SqlParameter returnValueParam = helper.AddReturnValueParameter(SqlDbType.Int); SqlDataReader dr; using (dr = helper.ExecuteReader("select UserID,SafeCode,UserRole from Users where UserName=@UserName and Password=@Password", CommandType.Text)) { if (dr.Read()) { user.UserID = dr.GetInt32(0); user.SafeCode = dr[1] == DBNull.Value ? null : (string)dr[1]; user.UserRole = (UserRoles)dr.GetInt16(2); } else { return(false); } } helper.ClearParameters(); helper.AddIntParameter("@UserID", user.UserID); helper.AddDateTimeParameter("@LastLoginTime", DateTime.Now); helper.GetBooleanValue("update Users set LastLoginTime=@LastLoginTime where UserID=@UserID", CommandType.Text); return(true); } }
public ActionResult ModifyPassword() { UserObj user = AppData.SessionUser; if (user == null) { return(Json(new { success = false, msg = "您还未登录" })); } UserBLL userBLL = new UserBLL(); UserObj userObj = userBLL.GetUserByID(user.UserID); Validation vld = new Validation(); string oldPassword = vld.Get("oldPassword"); string newPassword = vld.Get("newPassword"); oldPassword = Md5.MD5(oldPassword); if (oldPassword.ToUpper() != userObj.Password.ToUpper()) { return(Json(new { success = false, msg = "旧密码输入不正确!" })); } userObj.Password = Md5.MD5(newPassword); userBLL.ModifyUser(userObj); return(Json(new { success = true })); }
//___________________Adds a user from input from user, tests user ID and passes userObj to InsertToDb method_________ private void addUserButt_Click(object sender, EventArgs e) { if (Housekeeping.CheckAllFields(this)) { if (int.TryParse(userIDTxt.Text, out int ret)) //only accept int type for user ID { if (!test.UserObjDictionary.ContainsKey(int.Parse(userIDTxt.Text))) //Check user ID doesnt already exist { switch (accessGrpCbox.SelectedIndex) { case 0: { user = new AdminObj(); break; } case 1: { user = new LecturerObj(); break; } case 2: { user = new StudentObj(); break; } default: { break; } } user.UserID = int.Parse(userIDTxt.Text); user.Name = nameTxt.Text; user.Surname = surnameTxt.Text; user.Password = passwordTxt.Text; DatabaseUtilities.InsertToDB("Users", user); Housekeeping.ResetForm(this); //invoke delegate OnUserAdded(this, null); } else { MessageBox.Show("User ID already exists!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("User ID can only contain numbers!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("ALL FIELDS ARE REQUIRED!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public TwitchFollower(JToken followerData) { _createdAt = followerData.SelectToken("created_at").ToString(); if (followerData.SelectToken("notifications").ToString() == "true") _notifications = true; _user = new UserObj(followerData.SelectToken("user")); }
public bool IsPasswordChanged() { SqlParameter[] parameters = new SqlParameter[4]; parameters[0] = DataAccess.AddParameter("@GUID", UserObj.GlobalUniqueIDForResetPassword); parameters[1] = DataAccess.AddParameter("@password", UserObj.getPassword()); parameters[2] = DataAccess.AddParameter("@salt", UserObj.getSalt()); parameters[3] = DataAccess.AddParameter("@hash", UserObj.getHash()); DataTable dt = DataAccess.ExecuteDTByProcedure("SP_CHANGE_PASSWORD", parameters); if (dt == null) { return(false); } else { if (dt.Rows.Count > 0) { return(dt.Rows[0]["returnCode"].ToString().Equals("1")); } else { return(false); } } }
public string SaveUser(UserObj id) { UserManager userManager = new UserManager(); return(userManager.SaveUser(id)); }
private async Task SetNotesForCourseAsync(UserObj u) { var relationDb = await this._reaer.NotesForCourse .Qa() .Where(n => n.Creator == u.UserId) .ToListAsync(); if (relationDb == null || relationDb.Count == 0) { return; } u.Course = new List <D4LValue>(); foreach (var item in relationDb.Where(r => r.TaskId == Guid.Empty)) { var dv = new D4LValue { ClassId = item.ClassId, DsId = item.DsId, SectionId = item.SectionId }; dv.TaskToPage = new Dictionary <Guid, Guid>(); // 同班级同学程下任务 foreach (var task in relationDb.Where(r => r.TaskId != Guid.Empty && r.DsId == item.DsId && r.ClassId == item.ClassId)) { dv.TaskToPage.TryAdd(task.TaskId, task.PageId); } u.Course.Add(dv); } }
public CatalogHelper(UserObj uobj, string termIdx, string subIdx) { this.uobj = uobj; this.termIdx = termIdx; this.subIdx = subIdx; this.addAllitem(); }
public ActionResult SaveAddress() { UserObj user = AppData.SessionUser; if (user == null) { return(Json(new { success = false, msg = "您还未登录!" })); } UserBLL userBLL = new UserBLL(); Validation validation = new Validation(); int addressId = validation.GetInt("addressId"); AddressObj addressObj; if (addressId == 0) { addressObj = new AddressObj(); addressObj.AddressID = addressId; addressObj.UserID = user.UserID; } else { addressObj = userBLL.GetAddress(addressId); if (addressObj == null || addressObj.UserID != user.UserID) { return(Json(new { success = false, msg = "您无法修改该地址!" })); } } addressObj.Receiver = validation.Get("receiver", false, "收货人姓名不可为空!"); addressObj.Address = validation.Get("address", false, "详细地址不可为空!"); addressObj.Zip = validation.Get("zip"); addressObj.Mobile = validation.Get("mobile"); addressObj.Phone = validation.Get("phone"); addressObj.CityID = validation.GetInt("cityId"); addressObj.RegionID = validation.GetInt("regionId"); if (validation.HasError) { return(Json(new { success = false, msg = "参数错误!", errors = validation.GetErrors() })); } if (string.IsNullOrEmpty(addressObj.Phone) && string.IsNullOrEmpty(addressObj.Mobile)) { return(Json(new { success = false, msg = "手机或固话必填一项!" })); } if (addressObj.AddressID == 0) { userBLL.AddAddress(addressObj); } else { userBLL.ModifyAddress(addressObj); } return(Json(new { success = true })); }
/// <summary> /// Admin LogIn /// </summary> public void AdminLogIn() { ReEnterAdmin: Console.WriteLine("Enter login"); string userId = Console.ReadLine(); Console.WriteLine("Enter Pin code"); int pin = System.Convert.ToInt32(Console.ReadLine()); UserObj bo = new UserObj { ID = userId, pswd = pin }; LogInVerfication temp = new LogInVerfication(); Boolean verify = temp.AdminVerification(bo); SignedInUser s = new SignedInUser(); MenuView m = new MenuView(); if (verify == true) { NameAndPswd dataHolder = s.setValues(userId, pin); m.AdminMenu(); } else { char choose; ReEnter2: Console.WriteLine("\nYou have enetered invalid ID or PIN! Do you want to enter again (y/n)?\n"); try { choose = System.Convert.ToChar(Console.ReadLine()); } catch (Exception) { Console.WriteLine("Please choose correct optioin (y/n)"); goto ReEnter2; } if (choose.Equals('y') || choose.Equals('Y')) { goto ReEnterAdmin; } else if (choose.Equals('n') || choose.Equals('N')) { Console.Clear(); Console.WriteLine("/////////////////////////////////////////\n Welcome to ATM Managment System \n/////////////////////////////////////////\n"); AdminUserView v = new AdminUserView(); v.ChooseAdminUser(); } else { Console.WriteLine("Please choose right choice!"); goto ReEnter2; } } }
public TwitchFollower(JToken followerData) { _createdAt = followerData.SelectToken("created_at").ToString(); if (followerData.SelectToken("notifications").ToString() == "true") { _notifications = true; } _user = new UserObj(followerData.SelectToken("user")); }
public void Method(UserObj userobj, Guid recordid) { var t = System.Threading.Tasks.Task.Factory.StartNew <MyDataObject>(() => { return(DataManager.GetMyDataObject(userobj, recordid)); }); t.Wait(); }
public DataTable SelectUser() { SqlParameter[] parameters = new SqlParameter[2]; parameters[0] = DataAccess.AddParameter("@username", UserObj.Username); parameters[1] = DataAccess.AddParameter("@hash", UserObj.getHash()); DataTable dt = DataAccess.ExecuteDTByProcedure("sp_selectUser", parameters); return(dt == null ? new DataTable() : dt); }
public async Task Save(UserObj u) { if (u.IsNull(u => u.UserId)) { return; } await this._cachor.SetAsync(Key(u.UserId), u); }
public UserObj get() { // enter AD settings PrincipalContext AD = new PrincipalContext(ContextType.Domain, ConfigurationManager.AppSettings.Get("AD")); UserPrincipal u = new UserPrincipal(AD); UserObj user = new UserObj(); logger.Info("AD: {0}", ConfigurationManager.AppSettings.Get("AD")); // search for user u.SamAccountName = Environment.UserName; PrincipalSearcher search = new PrincipalSearcher(u); UserPrincipal result = (UserPrincipal)search.FindOne(); search.Dispose(); // show some details logger.Info("Display Name: {0}", result.DisplayName); user.DisplayName = result.DisplayName; logger.Info("Email: {0}", result.EmailAddress); user.Email = result.EmailAddress; string phone = result.VoiceTelephoneNumber; if (phone != null) { logger.Info("Phone Number : {0}", phone); try { user.Phone = result.VoiceTelephoneNumber; } catch (FormatException e) { logger.Error("Phone Number FormatException: {0}", phone); throw new FormatException(e.Message); } } DirectoryEntry d = (DirectoryEntry)result.GetUnderlyingObject(); string title = d.Properties["Title"]?.Value?.ToString(); if (title != null) { logger.Info("Title : {0}", title); user.Title = title; } string mobile = d.Properties["mobile"]?.Value?.ToString(); if (mobile != null) { logger.Info("Mobile : {0}", mobile); user.Mobile = mobile; } return(user); }
public ActionResult PMList() { UserObj user = AppData.SessionUser; if (user == null) { return(Redirect("/Login.html")); } return(View()); }
public void update(UserObj user, string appDataDir) { if (appDataDir != null) { // copy htm rtf txt files to target dir string sourceDir = path + "\\" + name; string[] fileEntries = Directory.GetFiles(sourceDir); foreach (string fileName in fileEntries) { logger.Info("file found: {0}", fileName); // Remove path from the file name. string fName = fileName.Substring(sourceDir.Length + 1); // copy files to target dir File.Copy(Path.Combine(sourceDir, fName), Path.Combine(appDataDir, fName), true); } // copy name_files directory to target string subDir = appDataDir + "\\" + name + "_files"; if (!Directory.Exists(subDir)) { logger.Info("Directory created: {0}", subDir); Directory.CreateDirectory(subDir); } string sourceDir2 = path + "\\" + name + "\\" + name + "_files"; string[] fileEntries2 = Directory.GetFiles(sourceDir2); foreach (string fileName in fileEntries2) { logger.Info("file found: {0}", fileName); // Remove path from the file name. string fName = fileName.Substring(sourceDir2.Length + 1); // copy files to target dir File.Copy(Path.Combine(sourceDir2, fName), Path.Combine(subDir, fName), true); } //update user info string[] fileEntries3 = Directory.GetFiles(appDataDir, name + "*"); foreach (string fileName in fileEntries3) { logger.Info("file found: {0}", fileName); string text = File.ReadAllText(fileName); text = text.Replace("GetProp(displayName)", user.DisplayName); text = text.Replace("GetProp(title)", user.Title); text = text.Replace("GetProp(telephoneNumber)", user.Phone); text = text.Replace("GetProp(mobile)", user.Mobile); text = text.Replace("GetProp(Mail)", user.Email); File.WriteAllText(fileName, text); logger.Info("User {0} template udpated", user.DisplayName); } } else { throw new Exception("appDataDir is empty"); } }
public UserResponse PasswordNotification(UserObj param) { bool email = DoesEmailExists(param.Email); if (email) { EmailObj emailModel = new EmailObj(); string AuthUsername = WebConfigurationManager.AppSettings["AuthUsername"]; string AuthPWD = WebConfigurationManager.AppSettings["AuthPWD"]; string PasswordUrl = WebConfigurationManager.AppSettings["PasswordUrl"]; var body = "Kindly click on this link to reset your password. </br>" + PasswordUrl + "?Email=" + param.Email; var message = new MailMessage(); message.To.Add(new MailAddress(param.Email)); // replace with valid value message.From = new MailAddress(WebConfigurationManager.AppSettings["SupportAddress"]); // replace with valid value message.Subject = "Password Update"; message.Body = string.Format(body, emailModel.FromEmail, emailModel.Message); message.IsBodyHtml = true; using (SmtpClient smtp = new SmtpClient()) { try { smtp.Host = WebConfigurationManager.AppSettings["EmailHost"]; smtp.EnableSsl = true; NetworkCredential NetworkCred = new NetworkCredential(AuthUsername, AuthPWD); smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; smtp.Port = Convert.ToInt32(WebConfigurationManager.AppSettings["EmailPort"]); smtp.Send(message); return(new UserResponse { RespCode = "00", RespMessage = "kindly check your email" }); } catch (Exception ex) { Log.InfoFormat("Email", ex.Message); return(new UserResponse { RespCode = "01", RespMessage = ex.Message }); } } } else { return(new UserResponse { RespCode = "01", RespMessage = "Invalid email address" }); } }
public IActionResult GenerateNewApiToken([FromRoute] string ApiKey, [FromBody] UserObj obj) { IActionResult response = Unauthorized(); UserApiTokenResponse resp = new UserApiTokenResponse(); try { UserJwt uj = GenerateJSONWebToken(); int ReturnVal; string ReturnMsg; UserApiTokenObj utj = new UserApiTokenObj(); utj.user_id = obj.user_id; utj.api_token = uj.token_String; utj.token_expiry = uj.expiry; SetUserApiToken(ApiKey, utj, out ReturnVal, out ReturnMsg); if (ReturnVal == 1) { resp.statuscode = (int)Common.ResponseStatusCode.Success; resp.message = "success"; resp.api_token = uj.token_String; response = Ok(resp); } else { resp.statuscode = (int)Common.ResponseStatusCode.SqlException; resp.message = ReturnMsg; response = Conflict(resp); } } catch (Exception ex) { Common c = new Common(); ExceptionObj exobj = c.GetExceptionObjBase(ex); exobj.form_name = "AuthentcationController"; exobj.page_url = "api/Authentication/GenerateNewApiToken"; int ReturnVal; string ReturnMsg; ExceptionDAO exd = new ExceptionDAO(_ConStr); exd.SetExceptionLog(ApiKey, exobj, out ReturnVal, out ReturnMsg); resp.statuscode = (int)Common.ResponseStatusCode.Exception; resp.message = ex.Message.ToString(); response = BadRequest(resp); } return(response); }