Exemplo n.º 1
0
        public ActionResult DeleteUser(string id, FormCollection Collection)
        {
            BzureUser user = Actor.Public.AsUserManager().GetUserByID(id);
            NotificationViewModel notification = new NotificationViewModel();
            if (user.IsNotNull())
            {
                if (Actor.Public.AsUserManager().DeleteUserByID(id))
                {
                    notification.Data = NotificationData.YES;
                    notification.Content = string.Format("用户:{0}删除成功", user.UserName);
                    notification.NotificationType = NotificationType.Success;

                }
                else
                {
                    notification.Data = NotificationData.NO;
                    notification.Content = string.Format("用户:{0}删除失败", user.UserName);
                    notification.NotificationType = NotificationType.Error;

                }
            }
            else
            {
                notification.Data = NotificationData.NO;
                notification.Content = string.Format("用户ID:{0}不存在!", id);
                notification.NotificationType = NotificationType.Attention;
            }
            return Result(notification);
        }
Exemplo n.º 2
0
        public ActionResult DeleteRole(string id)
        {

            TeamRole role = Actor.Public.GetRole(id);
            NotificationViewModel notification = new NotificationViewModel();
            if (role.IsNotNull())
            {
                Actor.Public.DeleteRole(id, (bool ok) =>
                {
                    if (ok)
                    {
                        notification.Data = NotificationData.YES;
                        notification.Content = string.Format("角色:{0}删除成功", role.Name);
                        notification.NotificationType = NotificationType.Success;

                    }
                    else
                    {
                        notification.Data = NotificationData.NO;
                        notification.Content = string.Format("角色:{0}删除失败", role.Name);
                        notification.NotificationType = NotificationType.Error;
                    }
                });

            }
            else
            {
                notification.Data = NotificationData.NO;
                notification.Content = string.Format("角色ID:{0}不存在!", id);
                notification.NotificationType = NotificationType.Attention;
            }

            return Result(notification);
        }
Exemplo n.º 3
0
        public ActionResult CreateRole(string id, string RoleName, string RoleDescription, FormCollection Collection)
        {
            TeamRole role = Actor.Public.CreateRole(RoleName, RoleDescription);
            NotificationViewModel notification = new NotificationViewModel();

            if (role.IsNotNull())
            {
                notification.Data = NotificationData.YES;
                notification.Content = string.Format("角色{0}创建成功", RoleName);
                notification.NotificationType = NotificationType.Success;
            }
            else
            {
                notification.Data = NotificationData.NO;
                notification.Content = string.Format("创建角色失败,可能{0}角色已经存在", RoleName);
                notification.NotificationType = NotificationType.Error;
            }
            return Result(notification);
        }
Exemplo n.º 4
0
        public ActionResult AuthorizeUser(string id, string UserState, FormCollection Collection)
        {
            BzureUser user = Actor.Public.AsUserManager().GetUserByID(id);
            if (user.IsNull())
            {
                return RedirectToAction("UserList");
            }
            //创建新的角色用户对应关系
            List<string> Roles = new List<string>();
            foreach (string key in Collection.AllKeys.Where(m => m.StartsWith("Role_")))
            {
                string roleid = Collection[key];
                if (roleid.IsNotNull())
                {
                    Roles.Add(roleid);
                }
            }
            user.State = UserState.IsNullOrEmpty() ? 0 : 1;
            NotificationViewModel notification = new NotificationViewModel();
            Actor.Public.AuthorizeUser(user, Roles.ToArray(), (bool ok) =>
            {
                if (ok)
                {
                    notification.Data = NotificationData.YES;
                    notification.Content = string.Format("用户:{0}授权保存成功", user.UserName);
                    notification.NotificationType = NotificationType.Success;
                }
                else
                {
                    notification.Data = NotificationData.NO;
                    notification.Content = string.Format("用户:{0}授权保存失败", user.UserName);
                    notification.NotificationType = NotificationType.Error;
                }
            });

            return Result(notification);
        }
Exemplo n.º 5
0
 public ActionResult ResetPassword(string id, FormCollection Collection)
 {
     BzureUser user = Actor.Public.AsUserManager().GetUserByID(id);
     if (user.IsNull())
     {
         return RedirectToAction("UserList");
     }
     string password = Collection["NewPassword"];
     NotificationViewModel notification = new NotificationViewModel();
     notification.Data = NotificationData.NO;
     notification.Content = string.Format("用户:{0}密码重置失败", user.UserName);
     notification.NotificationType = NotificationType.Error;
     if (Actor.Public.AsAccountManager().SetPassword(user.UserName, Actor.Public.AsAccountManager().EncryptPassword(password)))
     {
         notification.Data = NotificationData.YES;
         notification.Content = string.Format("用户:{0}密码重置成功", user.UserName);
         notification.NotificationType = NotificationType.Success;
     }
     return Result(notification);
 }
Exemplo n.º 6
0
        public ActionResult Config(string id, FormCollection Collection)
        {
            Type type = default(Type);
            foreach (KeyValuePair<Type, string> pair in Actor.Public.SystemRightTypes())
            {
                if (pair.Key.FullName == id)
                {
                    type = pair.Key;
                    break;
                }
            }

            // 创建新的对应关系
            Dictionary<string, int> dc = new Dictionary<string, int>();
            foreach (string key in Collection.AllKeys.Where(m => m.StartsWith("RT_")))
            {
                string roleid = key.Split('_')[1];
                string v = Collection[key];
                int value = int.Parse(v);
                if (dc.ContainsKey(roleid))
                {
                    int val = dc[roleid];
                    dc[roleid] = val + value;
                }
                else
                {
                    dc[roleid] = value;
                }
            }
            List<DroitResource> drs = new List<DroitResource>();
            foreach (KeyValuePair<string, int> pair in dc)
            {
                drs.Add(new DroitResource(Guid.NewGuid().ToString())
                {
                    ResourceName = id,
                    RoleID = pair.Key,
                    RightValue = pair.Value,
                    State = 1
                });
            }

            NotificationViewModel notification = new NotificationViewModel();
            Actor.Public.ResetDroitResource(id, drs.ToArray(), (bool ok) =>
            {
                if (ok)
                {
                    notification.Data = NotificationData.YES;
                    notification.Content = string.Format("{0}授权保存成功", EnumHelper.EnumName(type));
                    notification.NotificationType = NotificationType.Success;
                }
                else
                {
                    notification.Data = NotificationData.NO;
                    notification.Content = string.Format("{0}授权保存失败", EnumHelper.EnumName(type));
                    notification.NotificationType = NotificationType.Error;
                }
            });

            return Result(notification );
        }