protected void btnSave_Click(object sender, EventArgs e) { UserDal dal = new UserDal(); dal.SetPassword(Session["User"].ToString(), this.txtPassword.Text); ScriptManager.RegisterStartupScript(this.updatePanel, this.GetType(), "Message", "<script type=\"text/javascript\">alert('" + Resources.Resource.UserPwdUpdate_Success + "!');</script>", true); }
public string GetUid(Guid companyId, string sourceAccountId) { var userDal = new UserDal(); var uid = userDal.GetUid(companyId, sourceAccountId); return uid; }
protected void btnOK_Click(object sender, EventArgs e) { string Password = Js.Com.PageValidate.InputText(this.txtUserPwd.Text.Trim(), 30); byte[] buffer1 = UserPrincipal.EncryptPassword(Password); Js.BLL.Account.UserDal dal = new UserDal(cnKey); if(dal.UserPwdConfirm(Session["User"].ToString(), buffer1)) ClientScript.RegisterStartupScript(this.GetType(), "Submit", "<script type=\"text/javascript\">window.parent.returnValue ='1';window.parent.close();</script>"); else ClientScript.RegisterStartupScript(this.GetType(), "Message", "<script type=\"text/javascript\">alert('密碼不符');</script>"); }
// // GET: /Email/ public ActionResult SendEmail(long artistId) { IUserDal userDal = new UserDal(new ArtGalleryDBContext()); var user = userDal.Enitities.Find(artistId); EMailView eMailView = new EMailView() { LogOnModel = user}; ViewBag.Menu = "_ArtistHome"; ViewBag.Model = user; ViewBag.Title = user.UserName; return View(eMailView); }
public static bool HasPermission(IPrincipal user, IPermissions permissions) { ArtGalleryDBContext db = new ArtGalleryDBContext(); IUserDal userDal = new UserDal(db); var currentUser = GetCurrentUser(userDal, user); if (currentUser != null && currentUser.Permissions!=null) { if (currentUser.Permissions.Contains(permissions.Values)) return true; } return false; }
/// <summary> /// 更新用户信息 /// </summary> public static void UserDelete() { UserD = new UserDal(); UserD.UserUpdate(); }
/// <summary> /// 获取用户编号 /// </summary> /// <param name="userName">用户姓名</param> /// <returns>string类型,返回字符串类型用户编号</returns> public static string GetUserID(string userName) { UserD = new UserDal(); return(UserD.GetUserID(userName)); }
/// <summary> /// 获取用户信息 /// </summary> /// <param name="User">用户信息实体</param> /// <returns>int类型,0表示有用户,1表示没有用户</returns> public static int UserISNO(UserInfo User) { UserD = new UserDal(); return(UserD.UserSelect(User)); }
/// <summary> /// 添加用户信息 /// </summary> /// <param name="User">用户信息实体</param> public static void UserInsert(UserInfo User) { UserD = new UserDal(); UserD.UserInsert(User); }
public AuthenticationController(UserDal userDal) { this.userDal = userDal; }
public static void Main(string[] args) { Console.OutputEncoding = System.Text.Encoding.Default; //string connStr = ConfigurationManager.ConnectionStrings["ManagerNews"].ConnectionString; string connectionString = "Data Source=localhost;Initial Catalog=ManagerNews;Integrated Security=True"; topicDal = new TopicDal(connectionString); userDal = new UserDal(connectionString); commentDal = new CommentDal(connectionString); uint isLogIn = LogIn(); while (isLogIn != 0) { //Console.Clear(); Console.WriteLine("\n\n What do you want to DO?"); Console.WriteLine("\ntype 'l' to get List of entities"); Console.WriteLine("type 's' to Sort entity"); Console.WriteLine("type 'f' to Find entity"); if (isLogIn == 2) { Console.WriteLine("type 'a' to Add entity"); Console.WriteLine("type 'r' to Remove entity"); } //... Console.WriteLine("type 'o' to logOut"); Console.WriteLine("type 'q' to Quit"); try { char c = char.Parse(Console.ReadLine()); switch (c) { case 'l': //show list of entities { Console.WriteLine("\nList of all entity:"); PrintAll(); } break; case 's': // { Console.WriteLine("\nSorted by Title:"); PrintSorted(); } break; case 'a': //create new entity { Console.WriteLine("Add:"); AddUser(); } break; case 'r': //remove entity { Console.WriteLine("If you are the Owner or Administrator you can delete the user.\nEnter ID:"); if (isLogIn == 2) { int id = int.Parse(Console.ReadLine()); topicDal.Delete(id); } else { throw new Exception("Not permission"); } } break; case 'f': { Console.WriteLine("Please, enter a word or letters or a price: "); // find by Title string ttl = Console.ReadLine().ToString(); Find(ttl); } break; case 'o': { isLogIn = LogIn(); } break; case 'q': return; } } catch (Exception e) { Console.WriteLine(e.Message); } } }
protected void btnLogin_Click(object sender, EventArgs e) { string key = txtUserName.Text.ToLower(); if (Session["CheckCode"].ToString() != this.txtVerifyCode.Text.Trim()) { JScript.Instance.ShowMessage(this.updatePanel, Resources.Resource.InvalidCheckCode); return; } Js.BLL.BusinessUnit.EnterpriseDal dal = new Js.BLL.BusinessUnit.EnterpriseDal(); Js.Model.BusinessUnit.EnterpriseInfo model = dal.GetModel(this.txtEnterpriseID.Text.Trim()); if (model.EnterpriseName.Trim().Length <= 0) { JScript.Instance.ShowMessage(this.updatePanel, Resources.Resource.Login_Enterprise_NotExist); return; } cnKey = model.EnterpriseID; string userName = Js.Com.PageValidate.InputText(this.txtUserName.Text.Trim(), 30); string Password = Js.Com.PageValidate.InputText(this.txtUserPwd.Text.Trim(), 30); string UserCache = Convert.ToString(Cache[userName]); if (UserCache == null || UserCache == string.Empty || Cache[userName].ToString() == Page.Request.UserHostAddress) { UserPrincipal newUser = UserPrincipal.ValidateLogin(userName, Password,cnKey); if (newUser == null) { JScript.Instance.ShowMessage(this.updatePanel, Resources.Resource.LoginFailed + userName); ScriptManager.RegisterStartupScript(this.updatePanel, this.GetType(), "Reload", "checkwd_reload();", true); return; } else { UserDal currentUser = new UserDal(newUser,cnKey); Js.Model.Account.UsersInfo userModel = currentUser.GetModel(userName); Context.User = newUser; if (((SiteIdentity)User.Identity).TestPassword(Password,cnKey) == 0) { JScript.Instance.ShowMessage(this.updatePanel, Resources.Resource.InvalidPassword); } else { FormsAuthentication.SetAuthCookie(userName, false); Session["UserInfo"] = currentUser; Session["UserLevel"] = userModel.UserLevel; Session["UserType"] = "EP"; Session["User"] = userName; Session["EnterpriseID"] = model.EnterpriseID; Session["EnterpriseName"] = model.EnterpriseName; Session["cnKey"] = model.EnterpriseID; //Session["cnKey"] = "Enterprise"; TimeSpan stLogin = new TimeSpan(0, 0, System.Web.HttpContext.Current.Session.Timeout, 0, 0); //HttpContext.Current.Cache.Insert(key, Page.Request.UserHostAddress, null, DateTime.MaxValue, stLogin, System.Web.Caching.CacheItemPriority.NotRemovable, null); if (Session["returnPage"] != null) { string returnpage = Session["returnPage"].ToString(); Session["returnPage"] = null; Response.Redirect(returnpage); } else { Response.Redirect("~/Start.aspx"); //Response.Write("<script>window.parent.location.href='Start.aspx';</script>"); } } } } else { JScript.Instance.ShowMessage(this.updatePanel, Resources.Resource.TheUserLogined); return; } }
public void LoginWithUsernameAndPasswordisFail() { UserDal dal = new UserDal(); Assert.False(dal.CheckCredentials("usernameNot", "passwordNot")); }
public CustomUserStore(UserDal userDal_) { this.userDal = userDal_; }
public static UserInfo[] GetAllProjectLeads() { UserInfo[] userInfo = UserDal.GetAllProjectLeads(); return(userInfo); }
public static UserInfo GetUserById(int userId) { return(UserDal.GetUserById(userId)); }
public static int AddNewUser(UserInfo user) { return(UserDal.AddNewUser(user)); }
public void LoginWithUsernameAndPasswordisSuccessful() { UserDal dal = new UserDal(); Assert.True(dal.CheckCredentials("username", "password")); }
private UserActions() { dal = UserDal.getInstance(); }
public HomeController() { userDal = new UserDal(); deceasedDal = new DeceasedDal(); }
/// <summary> /// 获得选择地址框 /// </summary> /// <returns></returns> public string getSelectionHTML() { StringBuilder sb = new StringBuilder(); List <Model.Address> addrList = AddressDAL.m_AddressDal.GetList(string.Format(" UserId={0} ", UserDal.CurrentUser().UserId)); foreach (var addr in addrList) { sb.Append(string.Format(@"<option class=""txt sm w-sm"" value=""{0}"">{1}</option>", addr.AddressId, addr.DetailedAddress)); } return(sb.ToString()); }
protected void Login_Click(object sender, EventArgs e) { //Session["User"] = "******"; //FormsAuthentication.SetAuthCookie("Admin", false); //Response.Redirect("~/Start.aspx"); if (Session["CheckCode"].ToString() != this.txtVerifyCode.Text.Trim()) { JScript.Instance.ShowMessage(this.updatePanel, Resources.Resource.InvalidCheckCode); return ; } string userName = Js.Com.PageValidate.InputText(this.txtUserName.Text.Trim(), 30); string Password = Js.Com.PageValidate.InputText(this.txtUserPwd.Text.Trim(), 30); string UserCache = Convert.ToString(Cache[userName]); if (UserCache == null || UserCache == string.Empty || Cache[userName].ToString() == Page.Request.UserHostAddress) { UserPrincipal newUser = UserPrincipal.ValidateLogin(userName, Password); if (newUser == null) { JScript.Instance.ShowMessage(this.updatePanel, Resources.Resource.LoginFailed + userName); ScriptManager.RegisterStartupScript(this.updatePanel, this.GetType(), "Reload", "checkwd_reload();", true); return; } else { UserDal currentUser = new UserDal(newUser); Js.Model.Account.UsersInfo model = currentUser.GetModel(userName); Context.User = newUser; if (((SiteIdentity)User.Identity).TestPassword(Password) == 0) { JScript.Instance.ShowMessage(this.updatePanel, Resources.Resource.InvalidPassword); } else { FormsAuthentication.SetAuthCookie(userName, false); Session["UserInfo"] = currentUser; Session["UserLevel"] = model.UserLevel; Session["UserType"] = "BU"; Session["User"] = userName; if (Session["returnPage"] != null) { string returnpage = Session["returnPage"].ToString(); Session["returnPage"] = null; Response.Redirect(returnpage); } else { Response.Redirect("~/Start.aspx"); //Response.Write("<script>window.parent.location.href='Start.aspx';</script>"); } } } } else { JScript.Instance.ShowMessage(this.updatePanel, Resources.Resource.TheUserLogined); return; } }
public static string FindUser(User u) { return(UserDal.FindUser(u)); }
public static int Register(UserDto user) { Client u = UserDto.ToDal(user); return(UserDal.Register(u)); }
public MainWindow() { InitializeComponent(); userDal = new UserDal(connectionString); }
public static int AddGuestUser(UserDto user) { Client u = UserDto.ToDal(user); return(UserDal.AddGuestUser(u)); }
/// <summary> /// 判断是否存在用户 /// </summary> /// <param name="UserID">用户编号</param> /// <returns>bool类型,不存在返回true,存在返回false值</returns> public static bool GetUser(string UserID) { UserD = new UserDal(); return(UserD.GetUser(UserID)); }
public static string GetPasswordByemail(string email) { string password = UserDal.GetPasswordByemail(email); return(password); }
/// <summary> /// 更新用户密码 /// </summary> /// <param name="User">用户信息实体</param> public static void UserPwdUpdate(UserInfo User) { UserD = new UserDal(); UserD.UserPwdUpdate(User); }
public ActionResult Register(string name, string username, string telephone, string power, string password) { return(Content(UserDal.Register(name, username, telephone, power, password))); }
/// <summary> /// 获取用户信息 /// </summary> /// <returns>DateSet类型,返回用户信息数据集</returns> public static DataSet UserFill() { UserD = new UserDal(); return(UserD.UserFill()); }
public ActionResult List(string username, string password) { return(Content(UserDal.UserPower(username, password))); }
/// <summary> /// 读取用户信息 /// </summary> /// <param name="UserID">用户编号</param> /// <returns>UserInfo类型,存储用户信息实体</returns> public static UserInfo UserRead(string UserID) { UserD = new UserDal(); return(UserD.UserRead(UserID)); }
public void TestBlockUser() { //Arrange var controller = new ManagerControllerTests(); //Add Manager User UserDal usrDal = new UserDal(); User managerUser = new User { UserName = "******", Password = "******", rank = 1, Email = "*****@*****.**", EmailConfirmed = true, active = true }; usrDal.Users.Add(managerUser); usrDal.SaveChanges(); managerUser = usrDal.Users.SingleOrDefault(b => b.UserName == "TestManagerUser"); //Add to managing connection ManageConnectionDal magDal = new ManageConnectionDal(); ManageConnection magObj = new ManageConnection { managerId = managerUser.id, institution = 1, sYear = -1, department = -1 }; magDal.ManageConnections.Add(magObj); magDal.SaveChanges(); //Add User to be blocked User blockedUser = new User { UserName = "******", Password = "******", rank = 0, Email = "*****@*****.**", active = true, EmailConfirmed = true }; usrDal.Users.Add(blockedUser); usrDal.SaveChanges(); //Act controller.BlockUser(managerUser, "NewUser", DateTime.Now, 1, -1, -1); //Assert BlockedDal blkdal = new BlockedDal(); List <Blocked> blk = (from x in blkdal.Blockeds where x.UserName == blockedUser.UserName select x).ToList(); Assert.AreEqual(blk[0].UserName.Replace(" ", ""), blockedUser.UserName.Replace(" ", "")); //Clean up usrDal.Users.Remove(managerUser); usrDal.Users.Remove(blockedUser); usrDal.SaveChanges(); magDal.ManageConnections.Remove(magObj); magDal.SaveChanges(); blkdal.Blockeds.Remove(blk[0]); blkdal.SaveChanges(); }
/// <summary> /// 获取用户姓名 /// </summary> /// <param name="UserID">用户编号</param> /// <returns>string类型,返回字符串类型用户姓名</returns> public static string GetUserName(string UserID) { UserD = new UserDal(); return(UserD.GetUserName(UserID)); }
/// <summary> /// 加载数据 /// </summary> private void LoadData() { List <UserEntity> userList = UserDal.ListUsersByWarehouseCode(GlobeSettings.LoginedUser.WarehouseCode); this.gridControl3.DataSource = userList; }
public void Dispose() { userDal = null; }
/// <summary> /// 获得收货地址 /// </summary> /// <returns></returns> public string GetAddressHTML() { StringBuilder sb = new StringBuilder(); List <Address> addrList = AddressDAL.m_AddressDal.GetList(string.Format(" UserId={0}", UserDal.CurrentUser().UserId)); foreach (var addr in addrList) { string[] sArray = addr.DetailedAddress.Split('-'); string prov = sArray[0].ToString(); string city = sArray[1].ToString(); string dist = sArray[2].ToString(); string town = sArray[3].ToString(); string street = sArray[4].ToString(); string phone = addr.Tel; string recipient = addr.Recipient; int IsDefaultOrNot = addr.IsDefaultOrNot; #region 网页拼凑 sb.Append(string.Format(@"<div class=""addr""> <div class=""inner""> <div class=""addr-hd""> <span class=""prov"">{0}</span> <span class=""city"">{1}</span> <span>(</span> <span>{2}</span> <span>收)</span> </div> <div class=""addr-hd""> <span class=""dist"">{3}</span> <span class=""town"">{4}</span> <span class=""street"">{5}</span> <span class=""phone"">{6}</span> </div> <div class=""curMarker"" title=""{7}""></div> <div class=""defaultTip"" title=""{8}"">设为默认</div> </div> </div>", prov, city, recipient, dist, town, street, phone, addr.AddressId, IsDefaultOrNot)); #endregion } return(sb.ToString()); }
public static bool Regiater(UsrDto user) { Users u = UsrDto.Todal(user); return UserDal.Register(u); }
//public HttpResponseBase Response { get; } // //public WeChatApiDispatch() // { // } /// <summary> /// 微信信息xml格式 ///<xml> ///<ToUserName><![CDATA[toUser]]></ToUserName> ///<FromUserName><![CDATA[fromUser]]></FromUserName> ///<CreateTime>1348831860</CreateTime> ///<MsgType><![CDATA[image]]></MsgType> ///<PicUrl><![CDATA[this is a url]]></PicUrl> ///<MediaId><![CDATA[media_id]]></MediaId> ///<MsgId>1234567890123456</MsgId> ///</xml> /// </summary> /// <param name="postStr"></param> /// <returns></returns> public string Execute(string postStr) { XmlDocument doc = new XmlDocument(); doc.LoadXml(postStr); XmlElement rootElement = doc.DocumentElement; XmlNode MsgType = rootElement.SelectSingleNode("MsgType"); //RequestXML requestXML = new RequestXML(); string ToUserName = rootElement.SelectSingleNode("ToUserName").InnerText; string FromUserName = rootElement.SelectSingleNode("FromUserName").InnerText; string CreateTime = rootElement.SelectSingleNode("CreateTime").InnerText; string msgType = MsgType.InnerText; string resxml = string.Empty; string replyMsg = string.Empty; string defaultMsg = string.Empty; UserDal u3 = new UserDal(); //u3.Temp("全局XML数据:"+postStr); switch (msgType.ToLower()) { case "event": #region 事件消息 string eventType = rootElement.SelectSingleNode("Event").InnerText; if (!string.IsNullOrEmpty(eventType)) { UserBll ubll = new UserBll(); if (eventType == "subscribe") { //ubll.AddOpenId(FromUserName); replyMsg = @"世界那么大,我想去看看。钱包那么小,哪都去不了。既然如此,那就干脆来份水果,对自己好一点吧~ 新鲜水果,0元起送,30分钟极速送达,记得给老板一个赞哦~ 果然快,果然!快!好东西一定要跟身边的小伙伴分享哦 。 一大拨活动即将到达战场··· 敬请关注。"; } else if (eventType == "unsubscribe") { //ubll.RemoveOpenId(FromUserName);//取消关注删除用户 } } if (eventType.ToUpper() == "LOCATION") { //<Latitude>23.137466</Latitude> //<Longitude>113.352425</Longitude> //<Precision>119.385040</Precision> double Latitude =0; double Longitude =0; UserBll ubll = new UserBll(); try { Latitude = rootElement.SelectSingleNode("Latitude").InnerText.ToDouble(); Longitude = rootElement.SelectSingleNode("Longitude").InnerText.ToDouble(); if (!ubll.FindOpenId(FromUserName)) { ubll.AddOpenId(FromUserName); } if (ubll.SaveLocation(Longitude, Latitude, FromUserName)) { } } catch (Exception e) { } } #endregion break; case "view": break; case "text": string content = rootElement.SelectSingleNode("Content").InnerText; replyMsg = "对不起,您先稍等一下,小果果马上就来了,么么哒"; //文字消息 break; default: replyMsg = "default" + msgType; break; } #region 其他类型消息 // //无匹配消息 // resxml = @"<xml> // <ToUserName><![CDATA[" + FromUserName + @"]]></ToUserName> // <FromUserName><![CDATA[" + ToUserName + @"]]></FromUserName> // <CreateTime>" + DateTime.Now.DateTimeToInt() + @"</CreateTime> // <MsgType><![CDATA[text]]></MsgType> // <Content><![CDATA[" + defaultMsg + @"]></Content> // </xml>"; // //图文消息 // resxml = @"<xml> // <ToUserName><![CDATA[" + FromUserName + @"]]></ToUserName> // <FromUserName><![CDATA[" + ToUserName + @"]]></FromUserName> // <CreateTime>" + DateTime.Now.DateTimeToInt() + @"</CreateTime> // <MsgType><![CDATA[news]]></MsgType> // <ArticleCount>1</ArticleCount> // <Articles> // <item> // <Title><![CDATA[" + title + @"]]></Title> // <Description><![CDATA[" + msg + @"]]></Description> // <PicUrl><![CDATA[" + imgUrl + @"]]></PicUrl> // <Url><![CDATA[" + url + @"]]></Url> // </item> // </Articles> // </xml>"; // //关注后消息 // resxml = @"<xml> // <ToUserName><![CDATA[" + FromUserName + @"]]></ToUserName> // <FromUserName><![CDATA[" + ToUserName + @"]]></FromUserName> // <CreateTime>" + DateTime.Now.DateTimeToInt() + @"</CreateTime> // <MsgType><![CDATA[text]]></MsgType> // <Content><![CDATA[欢迎关注哦]]></Content> // </xml>"; #endregion msgType = "222"; resxml = @"<xml> <ToUserName> <![CDATA[" + FromUserName + @"]]> </ToUserName> <FromUserName> <![CDATA[" + ToUserName + @"]]> </FromUserName> <CreateTime> " + DateTime.Now.DateTimeToInt() + @" </CreateTime> <MsgType> <![CDATA[text]]> </MsgType> <Content> <![CDATA[" + replyMsg + @"]]> </Content></xml>"; return resxml; //ResponseText response = new ResponseText(info); //response.Content = "抱歉,此功能暂未开通。"; //result = response.ToXml(); }