public AccessTableVM()
        {
            //SetRightCommand = new Commands.DelegateCommand(SetRight);
            BackCommand = new Commands.DelegateCommand(o =>
                                                       NavigationService.Navigate(NavigationService.ExplorerPage));
            AddRoleCommand = new Commands.DelegateCommand(o =>
            {
                OsService.GetOS().RMon.AddRole(RoleName);
                RoleName = string.Empty;
                OnPropertyChanged("Roles");
            });
            RemoveRoleCommand = new Commands.DelegateCommand(o =>
            {
                OsService.GetOS().RMon.RemoveRole(SelectedRole);
                OnPropertyChanged("Roles");
                OnPropertyChanged("UsersRoles");
            });

            AddRoleToUserCommand = new Commands.DelegateCommand(o =>
            {
                OsService.GetOS().RMon.AddRoleToUser(SelectedUser, SelectedUserRole);
                OnPropertyChanged("UsersRoles");
            });
            RemoveRoleFromUserCommand = new Commands.DelegateCommand(o =>
            {
                OsService.GetOS().RMon.RemoveRoleFromUser(SelectedUser, SelectedUserRole);
                OnPropertyChanged("UsersRoles");
            });
        }
 public ExplorerVM()
 {
     os = OsService.GetOS();
     OpenFileCommand   = new Commands.DelegateCommand(OpenFile);
     CreateFileCommand = new Commands.DelegateCommand(CreateFile);
     RenameFileCommand = new Commands.DelegateCommand(RenameFile);
     RemoveFileCommand = new Commands.DelegateCommand(RemoveFile);
     NavigateCommand   = new Commands.DelegateCommand(Navigate);
 }
Example #3
0
 public void login(object o)
 {
     try
     {
         OsService.GetOS().Login(Name, Password);
         Name = Password = string.Empty;
         NavigationService.Navigate(NavigationService.SelectRolePage);
     }
     catch (OS.UserMgrException e)
     {
         MessageBox.Show(e.Message);
     }
 }
Example #4
0
 public void registrate(object o)
 {
     try
     {
         OsService.GetOS().Umgr.Registrate(Name, Password);
         OsService.GetOS().Login(Name, Password);
         Name = Password = string.Empty;
         //NavigationService.Navigate(NavigationService.ExplorerPage);
     }
     catch (OS.UserMgrException e)
     {
         MessageBox.Show(e.Message);
     }
 }
Example #5
0
 private void AccessMatrix_TextBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     try
     {
         TextBox       tb     = (TextBox)sender;
         OS.UserRole   role   = (OS.UserRole)((object[])tb.Tag)[0];
         OS.FileObject file   = (OS.FileObject)((object[])tb.Tag)[1];
         var           rights = OsService.GetOS().RMon.ParseRights(tb.Text);
         OsService.GetOS().RMon.SetRights(role, rights, file);
     }
     catch (OS.OsException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #6
0
 public SelectRoleVM()
 {
     SelectRoleCommand = new Commands.DelegateCommand(o => {
         var os = OsService.GetOS();
         os.SelectRole(SelectedUserRole);
         if (os.Sessions.HasSession(os.SessionId))
         {
             var res = MessageBox.Show("Продолжить существующую сессию?", "Сессия", MessageBoxButton.YesNo);
             if (res == MessageBoxResult.Yes)
             {
                 NavigationService.Navigate(NavigationService.ExplorerPage);
                 return;
             }
         }
         os.Sessions.StartSession(os.SessionId);
         NavigationService.Navigate(NavigationService.ExplorerPage);
     });
 }
Example #7
0
        void UpdateAccessMatrix()
        {
            var os = OsService.GetOS();

            Grid gMatrix = new Grid();

            gMatrix.VerticalAlignment   = VerticalAlignment.Top;
            gMatrix.HorizontalAlignment = HorizontalAlignment.Left;

            for (int i = 0; i < os.RMon.Roles.Count + 1; i++)
            {
                gMatrix.RowDefinitions.Add(new RowDefinition());
            }
            for (int i = 0; i < os.Fs.Files.Count + 1; i++)
            {
                gMatrix.ColumnDefinitions.Add(new ColumnDefinition());
            }

            for (int i = 0; i < os.Fs.Files.Count; i++)
            {
                var tbHeader = new TextBlock();
                tbHeader.Text = os.Fs.Files[i].ToString();
                tbHeader.VerticalAlignment = VerticalAlignment.Center;
                tbHeader.TextAlignment     = TextAlignment.Center;
                tbHeader.TextWrapping      = TextWrapping.Wrap;
                tbHeader.Margin            = new Thickness(3);

                gMatrix.Children.Add(tbHeader);
                Grid.SetRow(tbHeader, 0);
                Grid.SetColumn(tbHeader, i + 1);
            }
            int irole = 0;

            foreach (var role in os.RMon.Roles.Values)
            {
                var tbHeader = new TextBlock();
                tbHeader.Text = role.ToString();
                tbHeader.VerticalAlignment = VerticalAlignment.Center;
                tbHeader.TextAlignment     = TextAlignment.Center;
                tbHeader.TextWrapping      = TextWrapping.Wrap;
                tbHeader.Margin            = new Thickness(3);

                gMatrix.Children.Add(tbHeader);
                Grid.SetRow(tbHeader, irole + 1);
                Grid.SetColumn(tbHeader, 0);
                irole += 1;
            }

            irole = 0;
            foreach (var role in os.RMon.Roles.Values)
            {
                for (int i = 0; i < os.Fs.Files.Count; i++)
                {
                    var tbRights = new TextBox();
                    tbRights.Tag = new object[] { role, os.Fs.Files[i] };
                    var rights = os.RMon.Get(role, os.Fs.Files[i]);
                    tbRights.Text         = os.RMon.RightsToString(rights);
                    tbRights.TextChanged += AccessMatrix_TextBox_TextChanged;

                    gMatrix.Children.Add(tbRights);
                    Grid.SetRow(tbRights, irole + 1);
                    Grid.SetColumn(tbRights, i + 1);
                }
                irole += 1;
            }
            tiAccessMatrix.Content = gMatrix;
            //gAccessMatrix = gMatrix;
        }