Example #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) ? "新增设备角色" : "修改设备角色";
        }
Example #2
0
        public TimeGroupViewModel(TimeGroup timeGroup)
        {
            ViewModelAttachment = new ViewModelAttachment <TimeGroup>();
            SaveCmd             = new RelayCommand(Save);
            CancelCmd           = new RelayCommand(() => Close(""));

            TimeSegmentDtos = new ObservableCollection <SelectableItem>();
            foreach (var timeSegment in AllTimeSegments)
            {
                TimeSegmentDtos.Add(new ListBoxItem {
                    ID = timeSegment.TimeSegmentID, DisplayName = timeSegment.TimeSegmentName, IsSelected = false
                });
            }

            CurrentTimeGroup = timeGroup;
            if (timeGroup.TimeGroupID != 0)
            {
                TimeGroupID = timeGroup.TimeGroupID;
                Name        = timeGroup.TimeGroupName;
                Code        = timeGroup.TimeGroupCode;

                foreach (var timeSegment in timeGroup.TimeSegments)
                {
                    TimeSegmentDtos.First(t => t.ID == timeSegment.TimeSegmentID).IsSelected = true;
                }
            }
        }
Example #3
0
 public SysRoleViewModel()
 {
     SaveCmd             = new RelayCommand(Save);
     CancelCmd           = new RelayCommand(() => Close(""));
     ViewModelAttachment = new ViewModelAttachment <SysRole>();
     TreeViewSource      = BuildTreeViewSource();
 }
Example #4
0
        public FloorViewModel()
        {
            SaveCmd             = new RelayCommand(Save);
            CancelCmd           = new RelayCommand(() => Close(""));
            ViewModelAttachment = new ViewModelAttachment <Floor>();

            InitDoorListBox();
        }
Example #5
0
 public MoveUserViewModel(User userInfo)
 {
     SaveCmd             = new RelayCommand(Save);
     CancelCmd           = new RelayCommand(() => Close(""));
     ViewModelAttachment = new ViewModelAttachment <User>();
     CurrentUser         = userInfo;
     CurrentDepartment   = AuthorizationDepartments.First(x => x.DepartmentID == userInfo.DepartmentID);
 }
Example #6
0
        public UserAuthMngtViewModel(User currentUser)
        {
            SaveCmd   = new RelayCommand(Save);
            CancelCmd = new RelayCommand(() => Close(""));

            CurrentUser              = currentUser;
            ViewModelAttachment      = new ViewModelAttachment <User>();
            UserDeviceAuthViewModels = new ObservableCollection <UserDeviceAuthViewModel>(CreateUserDeviceAuthViewModels());
        }
Example #7
0
        public DeviceViewModel()
        {
            SaveCmd   = new RelayCommand(Save);
            CancelCmd = new RelayCommand(() => Close(""));

            ViewModelAttachment   = new ViewModelAttachment <DeviceController>();
            DoorViewModels        = new ObservableCollection <DeviceDoorViewModel>();
            HeadReadingViewModels = new ObservableCollection <DeviceHeadReadingViewModel>();
        }
Example #8
0
        public UserViewModel(User userInfo)
        {
            SaveCmd              = new RelayCommand(Save);
            CancelCmd            = new RelayCommand(() => Close(""));
            UploadImageCmd       = new RelayCommand <string>(UploadImage);
            DepartmentChangedCmd = new RelayCommand(ProcessDepartmentChangedCmd);

            CurrentUser         = userInfo;
            DepartmentInfo      = new Department();
            UserID              = userInfo.UserID;
            IsAddMode           = userInfo.UserID == 0;
            StartDate           = DateTime.Now;
            Birthday            = DateTime.Now;
            UserType            = UserType.Employee;
            ViewModelAttachment = new ViewModelAttachment <User>();
            Avator              = _userAvatorService.GetAvator(_userAvatorService.DefaultAvatorFileName);
            Title = IsAddMode ? "新增人员" : "修改人员";

            if (!IsAddMode) //Edit mode
            {
                UserType              = userInfo.Type;
                UserCode              = userInfo.UserCode;
                Name                  = userInfo.Name;
                Status                = userInfo.Status == GeneralStatus.Enabled;
                StartDate             = userInfo.StartDate;
                EndDate               = userInfo.EndDate;
                Phone                 = userInfo.Phone;
                Avator                = _userAvatorService.GetAvator(userInfo.Photo);
                DepartmentInfo        = AuthorizationDepartments.FirstOrDefault(d => d.DepartmentID == userInfo.DepartmentID);
                CurrentDepartmentName = DepartmentInfo.Name;
                Gender                = userInfo.Gender;
                LastName              = userInfo.UserPropertyInfo.FirstName;
                FirstName             = userInfo.UserPropertyInfo.FirstName;
                Nationality           = userInfo.UserPropertyInfo.Nationality;
                NativePlace           = userInfo.UserPropertyInfo.NativePlace;
                Birthday              = userInfo.UserPropertyInfo.Birthday;
                Marriage              = userInfo.UserPropertyInfo.Marriage;
                PoliticalStatus       = (userInfo.UserPropertyInfo.PoliticalStatus != null)
                    ? (PoliticalStatus)userInfo.UserPropertyInfo.PoliticalStatus : PoliticalStatus.Unknown;
                Degree = (userInfo.UserPropertyInfo.Degree != null)
                    ? (DegreeStatus)userInfo.UserPropertyInfo.Degree : DegreeStatus.Unknown;
                HomeNumber     = userInfo.UserPropertyInfo.HomeNumber;
                EnglishName    = userInfo.UserPropertyInfo.EnglishName;
                Company        = userInfo.UserPropertyInfo.Company;
                TechnicalTitle = userInfo.UserPropertyInfo.TechnicalTitle;
                TechnicalLevel = userInfo.UserPropertyInfo.TechnicalLevel;
                IDType         = userInfo.UserPropertyInfo.IDType;
                IDNumber       = userInfo.UserPropertyInfo.IDNumber;
                SocialNumber   = userInfo.UserPropertyInfo.SocialNumber;
                Email          = userInfo.UserPropertyInfo.Email;
                Address        = userInfo.UserPropertyInfo.Address;
                Postcode       = userInfo.UserPropertyInfo.Postcode;
                Remark         = userInfo.UserPropertyInfo.Remark;
            }

            DeviceRoleListBoxSource = GetDeviceRoleListBoxSource();
        }
Example #9
0
        public SysOperatorViewModel()
        {
            ViewModelAttachment = new ViewModelAttachment <SysOperator>();
            SaveCmd             = new RelayCommand(Save);
            CancelCmd           = new RelayCommand(() => Close(""));

            SysOperatorRoleItems = new ObservableCollection <ComboBoxItem>();
            SysPermissionProvider.GetInstance().AllSysRoles.ForEach(r =>
                                                                    SysOperatorRoleItems.Add(new ComboBoxItem()
            {
                ID = r.RoleID, DisplayName = r.RoleName
            }));
        }
    protected override bool InstallToViewModel(ref ModViewModelAddArgs a)
    {
        GameObject gameObject;

        if (this.isMesh && !a.isMesh)
        {
            return(base.InstallToViewModel(ref a));
        }
        if (!this.isMesh && a.isMesh)
        {
            return(base.InstallToViewModel(ref a));
        }
        if (a.vm == null)
        {
            Debug.Log("Viewmodel null for item attachment...");
        }
        if (this.attachObjectVM != null)
        {
            WeaponModRep weaponModRep = (WeaponModRep)a.modRep;
            if (!a.isMesh)
            {
                gameObject = this.GetSocketByName(a.vm, this.attachSocketName).InstantiateAsChild(this.attachObjectVM, true);
            }
            else
            {
                Socket socketByName = this.GetSocketByName(a.vm, this.attachSocketName);
                gameObject = UnityEngine.Object.Instantiate(this.attachObjectVM, socketByName.offset, Quaternion.Euler(socketByName.eulerRotate)) as GameObject;
                gameObject.transform.parent           = socketByName.parent;
                gameObject.transform.localPosition    = socketByName.offset;
                gameObject.transform.localEulerAngles = socketByName.eulerRotate;
            }
            gameObject.name = this.attachObjectVM.name;
            weaponModRep.SetAttached(gameObject, true);
            ViewModelAttachment component = gameObject.GetComponent <ViewModelAttachment>();
            if (component)
            {
                if (this.socketOverrideName != string.Empty && component is VMAttachmentSocketOverride)
                {
                    VMAttachmentSocketOverride vMAttachmentSocketOverride = (VMAttachmentSocketOverride)component;
                    this.SetSocketByname(a.vm, this.socketOverrideName, vMAttachmentSocketOverride.socketOverride);
                    if (this.modifyZoomOffset)
                    {
                        a.vm.punchScalar  = this.punchScalar;
                        a.vm.zoomOffset.z = this.zoomOffsetZ;
                    }
                }
                component.viewModel = a.vm;
            }
        }
        return(true);
    }
Example #11
0
        public TimeZoneViewModel(RldModel.TimeZone timeZone)
        {
            ViewModelAttachment = new ViewModelAttachment <RldModel.TimeZone>();
            SaveCmd             = new RelayCommand(Save);
            CancelCmd           = new RelayCommand(() => Close(""));

            CurrentTimeZone = timeZone;
            if (timeZone.TimeZoneID != 0)
            {
                ID   = timeZone.TimeZoneID;
                Name = timeZone.TimeZoneName;
                Code = timeZone.TimeZoneCode;
            }

            Title = (timeZone.TimeZoneID == 0) ? "新增时间区" : "修改时间区";
            TimeGroupAssociationsDtos = InitTimeZoneGroupDtos();
        }
 protected override void UninstallFromViewModel(ref ModViewModelRemoveArgs a)
 {
     if (this.attachObjectVM != null)
     {
         WeaponModRep        weaponModRep = (WeaponModRep)a.modRep;
         GameObject          gameObject   = weaponModRep.attached;
         ViewModelAttachment component    = gameObject.GetComponent <ViewModelAttachment>();
         if (component)
         {
             component.viewModel = null;
         }
         Socket socketByName = this.GetSocketByName(a.vm, this.attachSocketName);
         if (socketByName.attachParent == null)
         {
             Transform transforms = socketByName.parent;
         }
         if (gameObject)
         {
             weaponModRep.SetAttached(null, true);
             UnityEngine.Object.Destroy(gameObject.gameObject);
         }
     }
 }
Example #13
0
 public DeviceGroupViewModel()
 {
     SaveCmd             = new RelayCommand(Save);
     CancelCmd           = new RelayCommand(() => Close(""));
     ViewModelAttachment = new ViewModelAttachment <DeviceGroup>();
 }
Example #14
0
 public TimeSegmentViewModel()
 {
     ViewModelAttachment = new ViewModelAttachment <TimeSegment>();
     SaveCmd             = new RelayCommand(Save);
     CancelCmd           = new RelayCommand(() => Close(""));
 }