Exemple #1
0
        public DeviceRoleViewModel(DeviceRole deviceRole)
        {
            SaveCmd             = new RelayCommand(Save);
            CancelCmd           = new RelayCommand(() => Close(""));
            ViewModelAttachment = new ViewModelAttachment <DeviceRole>();

            var dtos = AuthorizationDevices.Select(x => new ListBoxItem
            {
                ID          = x.DeviceID,
                DisplayName = x.Name,
                IsSelected  = deviceRole.HasDeviceAuthorization(x.DeviceID)
            });

            DeviceDtos = new ObservableCollection <SelectableItem>(dtos);

            CurrentDeviceRole = deviceRole;
            if (deviceRole.DeviceRoleID != 0)
            {
                Name = deviceRole.RoleName;
                if (deviceRole.DeviceRolePermissions.Any())
                {
                    var firstPermission = deviceRole.DeviceRolePermissions.First();
                    SelectedTimezone         = Timezones.FirstOrDefault(x => x.TimeZoneID == firstPermission.AllowedAccessTimeZoneID);
                    SelectedPermissionAction = (int)firstPermission.PermissionAction;
                }
            }
            else
            {
                SelectedTimezone         = Timezones.FirstOrDefault();
                SelectedPermissionAction = PermissionActionDict.FirstOrDefault().ItemID.Value;
            }

            Title = (deviceRole.DeviceRoleID == 0) ? "新增设备角色" : "修改设备角色";
        }
Exemple #2
0
        public SyncDepartmentViewModel()
        {
            SaveCmd   = new RelayCommand(Save);
            CancelCmd = new RelayCommand(() => Close(""));
            SelectedTreeNodeChangedCmd      = new RelayCommand <TreeViewNode>(ShowUserBySelectedDepartmentNode);
            SelectDepartmentsCmd            = new RelayCommand(SelectDepartments);
            RemoveSelectedDepartmentCmd     = new RelayCommand(RemoveSelectedDepartment);
            SelectAllDepartmentsCmd         = new RelayCommand(SelectAllDepartments);
            RemoveAllSelectedDepartmentsCmd = new RelayCommand(RemoveAllSelectedDepartments);

            SelectedSyncDepartmentDtos = new ObservableCollection <SelectableItem>();

            var dtos = AuthorizationDevices.Select(x => new ListBoxItem {
                ID = x.DeviceID, DisplayName = x.Name
            });

            DeviceDtos = new ObservableCollection <SelectableItem>(dtos);
        }
Exemple #3
0
        public SyncUserViewModel()
        {
            SaveCmd   = new RelayCommand(Save);
            CancelCmd = new RelayCommand(() => Close(""));
            SelectedTreeNodeChangedCmd = new RelayCommand <TreeViewNode>(ShowUserBySelectedDepartmentNode);
            MoveToSelectedCmd          = new RelayCommand(MoveToSelected);
            RemoveSelectedCmd          = new RelayCommand(RemoveSelected);
            SelectedAllSourceUserCmd   = new RelayCommand(SelectAllDepartmentUsers);
            SelectedAllTargetUserCmd   = new RelayCommand(RemoveAllSelectedUsers);
            QueryDeviceUserCmd         = new RelayCommand(QueryDeviceUser);

            DepartmentUserDtos   = new ObservableCollection <SelectableItem>();
            SelectedSyncUserDtos = new ObservableCollection <SelectableItem>();
            DeviceUserDtos       = new ObservableCollection <SelectableItem>();

            var dtos = AuthorizationDevices.Select(x => new ListBoxItem {
                ID = x.DeviceID, DisplayName = x.Name
            });

            DeviceDtos = new ObservableCollection <SelectableItem>(dtos);
        }