private static IDictionary <string, SimpleRole> StaticBuildRoles() { IDictionary <string, SimpleRole> roles = new ConcurrentDictionary <string, SimpleRole>(4); SimpleRole admin = new SimpleRole(ADMIN); admin.add(_full); roles[ADMIN] = admin; SimpleRole architect = new SimpleRole(ARCHITECT); architect.add(_schema); architect.add(_readWrite); architect.add(_token); roles[ARCHITECT] = architect; SimpleRole publisher = new SimpleRole(PUBLISHER); publisher.add(_readWrite); publisher.add(_token); roles[PUBLISHER] = publisher; SimpleRole editor = new SimpleRole(EDITOR); editor.add(_readWrite); roles[EDITOR] = editor; SimpleRole reader = new SimpleRole(READER); reader.add(_read); roles[READER] = reader; return(roles); }
public override string[] FindUsersInRole(string roleName, string usernameToMatch) { try { List <string> Results = new List <string>(); Regex Expression = new Regex(usernameToMatch.Replace("%", @"\w*")); SimpleRole Role = CurrentStore.GetRole(roleName); if (Role != null) { foreach (string userName in Role.AssignedUsers) { if (Expression.IsMatch(userName)) { Results.Add(userName); } } } else { throw new ProviderException("Role does not exist!"); } return(Results.ToArray()); } catch { throw; } }
public ActionResult SaveRole(Guid?roleId, string roleName, string roleText, string[] functions, string applicationName) { bool result; IRoleInfo roleInfo = null; if (roleId == null) { roleInfo = WebSecurity.CreateRole(roleName, roleText); result = roleInfo != null; } else { result = WebSecurity.UpdateRoleText(roleText, roleId.Value); roleInfo = new SimpleRole(roleId.Value, roleName) { RoleText = roleText }; } if (result) { //更新角色功能列表 if (functions != null && functions.Length > 0) { result = WebSecurity.UpdateFunctionsForRole(roleInfo.RoleId, functions); if (result) { //移除当前功能列表的缓存 WebSecurity.RemoveFunctionCache(roleInfo.RoleId); } } } return(Json(new { Result = result, Data = roleInfo })); }
public override void AddUsersToRoles(string[] usernames, string[] roleNames) { try { // Get the roles to be modified foreach (string roleName in roleNames) { SimpleRole Role = CurrentStore.GetRole(roleName); if (Role != null) { foreach (string userName in usernames) { if (!Role.AssignedUsers.Contains(userName)) { Role.AssignedUsers.Add(userName); } } } } CurrentStore.Save(); } catch { throw; } }
public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames) { try { // Get the roles to be modified List <SimpleRole> TargetRoles = new List <SimpleRole>(); foreach (string roleName in roleNames) { SimpleRole Role = CurrentStore.GetRole(roleName); if (Role != null) { foreach (string userName in usernames) { if (Role.AssignedUsers.Contains(userName)) { Role.AssignedUsers.Remove(userName); } } } } CurrentStore.Save(); } catch { throw; } }
public override void CreateRole(string roleName) { try { SimpleRole NewRole = new SimpleRole(); NewRole.RoleName = roleName; NewRole.AssignedUsers = new StringCollection(); CurrentStore.Roles.Add(NewRole); CurrentStore.Save(); } catch { throw; } }
private static SimpleUser InitSuperAdmin() { List <IRole> roles = new List <IRole>(); SimpleRole role = new SimpleRole(); role.RoleID = "SUPER_ADMIN"; role.RoleName = "超级管理员"; role.Urls = GetModulesInRole(new Guid("69A61B69-B57F-480A-BCB2-5B71E5BF954A")); roles.Add(role); SimpleUser user = new SimpleUser(); user.LogonID = "SUPER_ADMIN"; user.DisplayName = "超级管理员"; user.Roles = roles; return(user); }
void Cache() { if (m_cache) { return; } m_cache = true; m_root = this.transform.parent; m_ani = this.GetComponent <Animation>(); m_simpleRole = m_root.GetComponent <SimpleRole>(); if (m_ani != null) { foreach (AnimationState st in m_ani) { if (st == null) { continue; } if (m_sts.ContainsKey(st.name)) { Debuger.LogError("{0}动作重复了:{1}", m_root.name, st.name); continue; } m_sts[st.name] = st; } } else { Debuger.LogError("角色找不到Animation"); } //动作特效预加载 foreach (AniFxGroup g in m_groups) { g.Init(this); } //找到模型名 m_modName = m_root.name; if (m_modName.EndsWith("(Clone)")) { m_modName = m_modName.Substring(0, m_modName.Length - 7); } }
public override bool IsUserInRole(string username, string roleName) { try { SimpleRole Role = CurrentStore.GetRole(roleName); if (Role != null) { return(Role.AssignedUsers.Contains(username)); } else { throw new ProviderException("Role does not exist!"); } } catch { throw; } }
public override bool DeleteRole(string roleName, bool throwOnPopulatedRole) { try { SimpleRole Role = CurrentStore.GetRole(roleName); if (Role != null) { CurrentStore.Roles.Remove(Role); CurrentStore.Save(); return(true); } else { return(false); } } catch { throw; } }
// 获取用户的角色集合 private static List <IRole> GetUserPermissions(string employeeID) { List <IRole> roles = new List <IRole>(); List <SPhone_Role> lst = null; using (var db = DCHelper.SPhoneContext()) { List <Guid> rids = db.SPhone_UserPermission.Where(rm => rm.EmployeeID == employeeID).Select(rm => rm.RoleID).ToList(); lst = db.SPhone_Role.ToList(); rids.ForEach(id => { SPhone_Role role = lst.Find(m => m.RoleID == id); if (role != null) { SimpleRole model = new SimpleRole(); model.RoleID = role.RoleID.ToString(); model.RoleName = role.RoleName; model.Urls = GetModulesInRole(role.RoleID); roles.Add(model); } }); } return(roles); }
public SimpleRoleFreeState(SimpleRole r) : base(r) { }
public SimpleRoleState(SimpleRole r) { m_parent = r; }
public SimpleRoleAttackState(SimpleRole r) : base(r) { }
public SimpleRoleBehitState(SimpleRole r) : base(r) { }
public override void OnInspectorGUI() { //base.OnInspectorGUI(); SimpleRole r = target as SimpleRole; EditorGUI.BeginChangeCheck(); r.m_showDebug = EditorGUILayout.Toggle("显示调试界面", r.m_showDebug); r.m_isEmpty = EditorGUILayout.Toggle("无模型角色", r.m_isEmpty); if (!r.m_isEmpty) { EditorGUILayout.Space(); r.m_moveAniSpeed = EditorGUILayout.FloatField("跑步动作调整(防滑步)", r.m_moveAniSpeed); r.m_moveSpeed = EditorGUILayout.FloatField("跑步速度", r.m_moveSpeed); r.m_needFade = EditorGUILayout.Toggle("是否渐变", r.m_needFade); if (r.m_needFade) { r.m_fade = EditorGUILayout.FloatField("所有被击渐变时间", r.m_fade); } r.m_needResetPos = EditorGUILayout.Toggle("是否复位", r.m_needResetPos); EditorGUILayout.Space(); r.m_behitDuration = EditorGUILayout.FloatField("被击时间", r.m_behitDuration); EditorGUILayout.Space(); r.m_floatBehitStartSpeed = EditorGUILayout.FloatField("被击时的初速度", r.m_floatBehitStartSpeed); r.m_floatBehitAccelerated = EditorGUILayout.FloatField("被击时的加速度", r.m_floatBehitAccelerated); r.m_floatStartSpeed = EditorGUILayout.FloatField("浮空初速度", r.m_floatStartSpeed); r.m_floatAcceleratedUp = EditorGUILayout.FloatField("上升时的加速度", r.m_floatAcceleratedUp); r.m_floatAcceleratedDown = EditorGUILayout.FloatField("下落时的加速度", r.m_floatAcceleratedDown); r.m_floatSpeedUpLimit = EditorGUILayout.FloatField("速度上限", r.m_floatSpeedUpLimit); r.m_floatSpeeDownLimit = EditorGUILayout.FloatField("速度下限", r.m_floatSpeeDownLimit); EditorGUILayout.Space(); r.m_flyStartSpeed = EditorGUILayout.FloatField("击飞初速度", r.m_flyStartSpeed); r.m_flyAcceleratedUp = EditorGUILayout.FloatField("上升时的加速度", r.m_flyAcceleratedUp); r.m_flyAcceleratedDown = EditorGUILayout.FloatField("下落时的加速度", r.m_flyAcceleratedDown); r.m_flySpeedUpLimit = EditorGUILayout.FloatField("速度上限", r.m_flySpeedUpLimit); r.m_flySpeeDownLimit = EditorGUILayout.FloatField("速度下限", r.m_flySpeeDownLimit); EditorGUILayout.Space(); r.m_groundDuration = EditorGUILayout.FloatField("倒地时间", r.m_groundDuration); EditorGUILayout.Space(); Animation ani = r.transform.Find("model").GetComponent <Animation>(); if (ani == null) { EditorGUILayout.LabelField("找不到model的Animation,不能设置动作"); return; } string[] aniNames = ani.GetNames(); if (aniNames == null || aniNames.Length == 0) { EditorGUILayout.LabelField("Animation没有动作"); return; } DrawAtk("Num4攻击键", r, r.m_num4Atk, ani, aniNames); DrawAtk("Num5攻击键", r, r.m_num5Atk, ani, aniNames); DrawAtk("Num6攻击键", r, r.m_num6Atk, ani, aniNames); } if (EditorGUI.EndChangeCheck()) { //Debuger.Log("修改"); EditorUtil.SetDirty(r); } }
public void DrawAtk(string title, SimpleRole r, SimpleRole.AttackCxt c, Animation ani, string[] aniNames) { if (EditorUtil.DrawHeader(string.Format("{0}:{1}", title, c.aniName))) { using (new AutoContent()) { int idxOld = Array.IndexOf(aniNames, c.aniName); if (idxOld == -1 && !string.IsNullOrEmpty(c.aniName)) { c.aniName = ""; } int idx = UnityEditor.EditorGUILayout.Popup("动作名", idxOld, aniNames); if (idx != idxOld) { c.aniName = aniNames[idx]; } AnimationState aniSt = ani[c.aniName]; if (aniSt == null) { EditorGUILayout.LabelField("无动作"); return; } c.wrapMode = (WrapMode)EditorGUILayout.EnumPopup("循环模式", c.wrapMode); //不用clamp,强制切到ClampForever if (c.wrapMode == WrapMode.Clamp) { c.wrapMode = WrapMode.ClampForever; } //持续时间 if (c.wrapMode == WrapMode.Loop || c.wrapMode == WrapMode.ClampForever || c.wrapMode == WrapMode.PingPong) { c.duration = EditorGUILayout.FloatField("持续时间", c.duration); } else { if (c.duration > 0) { c.duration = 0; } } //旋转 c.canRotate = EditorGUILayout.Toggle("可旋转", c.canRotate); if (c.canRotate) { c.rotateSpeed = EditorGUILayout.FloatField("旋转速度", c.rotateSpeed); } //移动 c.canMove = EditorGUILayout.Toggle("可移动", c.canMove); if (c.canMove) { c.moveSpeed = EditorGUILayout.FloatField("移动速度", c.moveSpeed); } } } }
public SimpleRoleMoveState(SimpleRole r) : base(r) { }
private bool TryGetRoles(out List <SimpleRole> roles, LoginUser user) { roles = qRepository.Entities.First(o => o.ID == user.ID).UserRoles.Select(o => SimpleRole.CreateRole(o.RoleID, o.Role.RoleName)).ToList(); return(roles != null); }