void BindData(List<Profile> plst, ProfileToken tok) { plst.ForEach(x => profCollection.Add(x) ); //profilesList.ItemsSource = profCollection; //profilesList.DisplayMemberPath = "Name"; profilesList.SelectionChanged += (object sender, SelectionChangedEventArgs e) => { if (profilesList.SelectedItem != null) { if (profilesList.SelectedItem == currentProf || ((Profile)profilesList.SelectedItem).@fixed) deleteSelected.IsEnabled = false; else deleteSelected.IsEnabled = true; } else { deleteSelected.IsEnabled = false; } }; try { currentProf = plst.Find(x => x.token == tok); selectedProf = currentProf; profilesList.SelectedItem = currentProf; } catch (Exception err) { dbg.Error(err); } }
/// <summary> /// 身份验证 account=null 的时候去数据库查询 /// </summary> /// <param name="account">用户名</param> /// <param name="token">token</param> /// <returns></returns> public ProfileToken Identity(string token) { string[] profiles = new string[3]; try { /* * profiles[0] 用户ID * profiles[1] 用户Account * profiles[2] token 产生日期 */ profiles = CryptoHelper.TripleDesDecrypting(token).Split(','); } catch { throw new Exception("Illegal token."); } ProfileToken u = null; if (Const.RedisConfigure.Default().Switch) { u = Redis.RedisHelper.Get <ProfileToken>("sys_member:" + profiles[1]); if (u != null) { Redis.RedisHelper.KeyExpire("sys_member:" + profiles[1], Convert.ToInt32(Const.RedisConfigure.Default().ExpiryDate.Minutes)); if (u.Profile == token) { return(u); } } return(null); } else { return(_db.Queryable <ProfileToken>().AS("sys_member").Where(m => (m.Profile == token && m.State == 1)).First()); } }
void BindData(List <Profile> plst, ProfileToken tok) { plst.ForEach(x => profCollection.Add(x) ); //profilesList.ItemsSource = profCollection; //profilesList.DisplayMemberPath = "Name"; profilesList.SelectionChanged += (object sender, SelectionChangedEventArgs e) => { if (profilesList.SelectedItem != null) { if (profilesList.SelectedItem == currentProf || ((Profile)profilesList.SelectedItem).@fixed) { deleteSelected.IsEnabled = false; } else { deleteSelected.IsEnabled = true; } } else { deleteSelected.IsEnabled = false; } }; try { currentProf = plst.Find(x => x.token == tok); selectedProf = currentProf; profilesList.SelectedItem = currentProf; } catch (Exception err) { dbg.Error(err); } }
/// <summary> /// 获取权限根节点 /// </summary> /// <param name="profile"></param> /// <returns></returns> public ActionResult GetUsrFc(ProfileToken profile) { if (profile == null) { return(new ActionResult(false, null, null, "无权访问,你的IP已经被记录!")); } object rootFunc = _db.Ado.SqlQuery <dynamic>(@"SELECT * FROM sys_func f WHERE `show`=1 and f.pid is null AND f.id in( SELECT DISTINCT frl.fid FROM sys_func_roles_link frl WHERE frl.rid in ( SELECT rid from sys_member_roles_link lmr WHERE lmr.mid=" + profile.ID + ")) order by forder asc"); return(new ActionResult(true, rootFunc)); }
/// <summary> /// 返回用户的功能点 /// </summary> /// <param name="profile"></param> /// <returns></returns> public ActionResult GetFunc(ProfileToken profile) { var usr = profile; if (usr != null) { object funcList = _db.Ado.SqlQuery <dynamic>(@"SELECT * FROM sys_func f WHERE `show`=1 and f.pid is not null AND f.id in( SELECT DISTINCT frl.fid FROM sys_func_roles_link frl WHERE frl.rid in ( SELECT rid from sys_member_roles_link lmr WHERE lmr.mid=" + usr.ID + ")) order by forder asc"); return(new ActionResult(true, funcList)); } return(new ActionResult(false, null, null, "用户身份不能为空!")); }
public PropertyProfileEditor(List<Profile> plst, ProfileToken profileToken, Action createNew, Action<Profile> renameProfile, Action<Profile> selectProfile, Action<Profile> deleteProfile) { profCollection = new ObservableCollection<Profile>(); InitializeComponent(); profilesList.SelectionMode = SelectionMode.Single; onCreateNew = createNew; onRenameProfile = renameProfile; onDeleteProfile = deleteProfile; onSelectProfile = selectProfile; Localization(); InitControl(); BindData(plst, profileToken); }
public PropertyProfileEditor(List <Profile> plst, ProfileToken profileToken, Action createNew, Action <Profile> renameProfile, Action <Profile> selectProfile, Action <Profile> deleteProfile) { profCollection = new ObservableCollection <Profile>(); InitializeComponent(); profilesList.SelectionMode = SelectionMode.Single; onCreateNew = createNew; onRenameProfile = renameProfile; onDeleteProfile = deleteProfile; onSelectProfile = selectProfile; Localization(); InitControl(); BindData(plst, profileToken); }