//private int _iDiscount; public MyIdentity(DXInfo.Models.aspnet_CustomProfile oper, DXInfo.Models.aspnet_Users user, DXInfo.Models.Depts dept, string authenticationType) { this._oper = oper; this._AuthenticationType = authenticationType; //this._iDiscount = discount; this._dept = dept; this._user = user; }
private void Button_Click(object sender, RoutedEventArgs e) { if (cbLocalDept.SelectedItem != null) { var q = from n in uow.NameCode.GetAll() where n.Type == "LocalDept" select n; if (q.Count() == 0) { DXInfo.Models.Depts d = cbLocalDept.SelectedItem as DXInfo.Models.Depts; DXInfo.Models.NameCode nc = new DXInfo.Models.NameCode(); nc.Type = "LocalDept"; nc.Code = "001"; nc.Name = "本地部门"; nc.Value = d.DeptId.ToString(); nc.Comment = "启用于:" + DateTime.Now.ToString(); uow.NameCode.Add(nc); uow.Commit(); } } this.Close(); }
private void login() { string userName = this.UserName; string passwd = this.Password; if (string.IsNullOrWhiteSpace(userName)) { MessageBox.Show("请输入用户名"); return; } if (string.IsNullOrWhiteSpace(passwd)) { MessageBox.Show("请输入密码"); return; } if (!Membership.ValidateUser(userName, passwd)) { MessageBox.Show("用户名或密码错误,多次错误后此用户将被锁定"); return; } MembershipUser user = Membership.GetUser(userName); if (user == null) { throw new ArgumentException("操作员信息错误"); } Guid userId = Guid.Parse(user.ProviderUserKey.ToString()); DXInfo.Models.aspnet_CustomProfile oper = Uow.aspnet_CustomProfile.GetById(g => g.UserId == userId); if (oper == null) { throw new ArgumentException("操作员信息错误"); } DXInfo.Models.aspnet_Users auser = Uow.aspnet_Users.GetById(g => g.UserId == userId); var nc = Uow.NameCode.GetAll().Where(w => w.Type == "LocalDept").FirstOrDefault(); if (nc == null) { MessageBox.Show("请首先设置本地门店", "设置本地门店", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (string.IsNullOrEmpty(nc.Value)) { MessageBox.Show("本地门店信息错误", "设置本地门店", MessageBoxButton.OK, MessageBoxImage.Error); return; } Guid deptId = Guid.Parse(nc.Value); if (!oper.DeptId.HasValue) { MessageBox.Show("请设置操作员门店信息"); return; } if (oper.DeptId.Value != deptId && userName != "admin") { MessageBox.Show("不是这个门店操作员,不能登录"); return; } DXInfo.Models.Depts dept = Uow.Depts.GetById(g => g.DeptId == deptId); if (dept == null) { throw new ArgumentException("门店信息错误"); } DXInfo.Principal.MyIdentity mi = new DXInfo.Principal.MyIdentity(oper, auser, dept, "MyIdentity"); List <DXInfo.Models.aspnet_Sitemaps> lFunc = GetAllSitemapKeys(oper.UserId, auser.UserName); DXInfo.Principal.MyPrincipal mp = new DXInfo.Principal.MyPrincipal(mi, lFunc); if (Thread.CurrentPrincipal == null) { AppDomain.CurrentDomain.SetThreadPrincipal(mp); } else { Thread.CurrentPrincipal = mp; } //Uow.Dispose(); this.UserName = null; this.Password = null; var rmw = ServiceLocator.Current.GetInstance <RibbonMainWindow>(); App.Current.MainWindow = rmw; rmw.Show(); Messenger.Default.Send(new CloseViewMessageToken()); }
public MyIdentity() { this._oper = new Models.aspnet_CustomProfile(); this._AuthenticationType = "MyIdentity"; this._dept = new Models.Depts(); }