コード例 #1
0
 public ResourceScreenItemViewModel(ResourceScreenItem model, ResourceScreen screen,
     ICommand actionCommand, bool isTicketSelected, bool userPermittedToMerge, ResourceState state)
 {
     _actionCommand = actionCommand;
     _screen = screen;
     _isTicketSelected = isTicketSelected;
     _userPermittedToMerge = userPermittedToMerge;
     ResourceState = state;
     Model = model;
 }
コード例 #2
0
 public void Refresh(ResourceScreen resourceScreen, EntityOperationRequest<Resource> currentOperationRequest)
 {
     _resourceService.UpdateResourceScreen(resourceScreen);
     if (_currentResourceScreen != resourceScreen || Widgets == null)
     {
         _currentResourceScreen = resourceScreen;
         Widgets = new ObservableCollection<IDiagram>(resourceScreen.Widgets.Select(WidgetCreatorRegistry.CreateWidgetViewModel));
     }
     Widgets.Where(x => x.AutoRefresh).ToList().ForEach(x => x.Refresh());
     RaisePropertyChanged(() => Widgets);
 }
コード例 #3
0
 public IEnumerable<ResourceScreenItem> GetCurrentResourceScreenItems(ResourceScreen resourceScreen, int currentPageNo, string resourceStateFilter)
 {
     UpdateResourceScreenItems(resourceScreen, currentPageNo);
     if (resourceScreen != null)
     {
         if (resourceScreen.PageCount > 1)
         {
             return resourceScreen.ScreenItems
                  .OrderBy(x => x.SortOrder)
                  .Where(x => string.IsNullOrEmpty(resourceStateFilter) || x.ResourceState == resourceStateFilter)
                  .Skip(resourceScreen.ItemCountPerPage * currentPageNo)
                  .Take(resourceScreen.ItemCountPerPage);
         }
         return resourceScreen.ScreenItems.Where(x => string.IsNullOrEmpty(resourceStateFilter) || x.ResourceState == resourceStateFilter);
     }
     return new List<ResourceScreenItem>();
 }
コード例 #4
0
        public IEnumerable<ResourceScreenItem> GetCurrentResourceScreenItems(ResourceScreen resourceScreen, int currentPageNo, int resourceStateFilter)
        {
            UpdateResourceScreenItems(resourceScreen, currentPageNo);

            if (resourceScreen != null)
            {
                if (resourceScreen.PageCount > 1)
                {
                    return resourceScreen.ScreenItems
                         .OrderBy(x => x.Order)
                         .Where(x => x.ResourceStateId == resourceStateFilter || resourceStateFilter == 0)
                         .Skip(resourceScreen.ItemCountPerPage * currentPageNo)
                         .Take(resourceScreen.ItemCountPerPage);
                }
                return resourceScreen.ScreenItems.Where(x => x.ResourceStateId == resourceStateFilter || resourceStateFilter == 0);
            }
            return new List<ResourceScreenItem>();
        }
コード例 #5
0
ファイル: ResourceDao.cs プロジェクト: neapolis/SambaPOS-3
        public void UpdateResourceScreenItems(ResourceScreen resourceScreen, int pageNo)
        {
            if (resourceScreen == null) return;

            IEnumerable<int> set;
            if (resourceScreen.PageCount > 1)
            {
                set = resourceScreen.ScreenItems
                    .OrderBy(x => x.SortOrder)
                    .Skip(pageNo * resourceScreen.ItemCountPerPage)
                    .Take(resourceScreen.ItemCountPerPage)
                    .Select(x => x.ResourceId);
            }
            else set = resourceScreen.ScreenItems.OrderBy(x => x.SortOrder).Select(x => x.ResourceId);
            using (var w = WorkspaceFactory.CreateReadOnly())
            {
                var result = w.Queryable<ResourceStateValue>().Where(x => set.Contains(x.ResoruceId));
                result.ToList().ForEach(x =>
                {
                    var screeenItem = resourceScreen.ScreenItems.Single(y => y.ResourceId == x.ResoruceId);
                    screeenItem.ResourceState = x.GetStateValue(resourceScreen.DisplayState);
                });
            }
        }
コード例 #6
0
 public ResourceScreen SetSelectedResourceScreen(ResourceScreen resourceScreen)
 {
     if (IsLocked && ActiveResourceScreen == null) ActiveResourceScreen = SelectedResourceScreen;
     else if (!IsLocked && ActiveResourceScreen != null)
     {
         resourceScreen = ActiveResourceScreen;
         ActiveResourceScreen = null;
     }
     SelectedResourceScreen = resourceScreen;
     return resourceScreen;
 }
コード例 #7
0
 public void SetSelectedResourceScreen(ResourceScreen resourceScreen)
 {
     SelectedResourceScreen = resourceScreen;
 }
コード例 #8
0
 protected override void BeforeEditSettings()
 {
     _resourceScreen = null;
     Settings.StateFilterNameValue.UpdateValues(_cacheService.GetStates(0).Select(x => x.Name));
 }
コード例 #9
0
        public void ResetState()
        {
            _departmentService.Reset();

            var did = CurrentDepartment.Id;
            CurrentDepartment = null;
            SetCurrentDepartment(did);

            var rid = SelectedResourceScreen.Id;
            if (CurrentDepartment != null)
                SelectedResourceScreen = CurrentDepartment.ResourceScreens.Single(x => x.Id == rid);
        }
コード例 #10
0
 private List<ResourceScreenItem> GetResourceScreenItems(ResourceScreen resourceScreen, string stateFilter)
 {
     if (resourceScreen.ScreenItems.Count > 0)
         return _resourceService.GetCurrentResourceScreenItems(resourceScreen, CurrentPageNo, stateFilter).OrderBy(x => x.SortOrder).ToList();
     return
         _resourceService.GetResourcesByState(stateFilter, resourceScreen.ResourceTypeId).Select(x => new ResourceScreenItem { ResourceId = x.Id, Name = x.Name, ResourceState = stateFilter }).ToList();
 }
コード例 #11
0
 public void UpdateResourceScreenItems(ResourceScreen resourceScreen, int pageNo)
 {
     _resourceDao.UpdateResourceScreenItems(resourceScreen, pageNo);
 }
コード例 #12
0
 private List<ResourceScreenItem> GetResourceScreenItems(ResourceScreen resourceScreen, int stateFilter)
 {
     _applicationStateSetter.SetSelectedResourceScreen(resourceScreen);
     if (resourceScreen.ScreenItems.Count > 0)
         return _resourceService.GetCurrentResourceScreenItems(resourceScreen, CurrentPageNo, stateFilter).OrderBy(x => x.Order).ToList();
     return
         _resourceService.GetResourcesByState(stateFilter, resourceScreen.ResourceTemplateId).Select(x => new ResourceScreenItem { ResourceId = x.Id, Name = x.Name, ResourceStateId = stateFilter }).ToList();
 }
コード例 #13
0
 public void Refresh(ResourceScreen resourceScreen, EntityOperationRequest<Resource> currentOperationRequest)
 {
     _currentOperationRequest = currentOperationRequest;
     UpdateResourceScreenItems(resourceScreen);
 }
コード例 #14
0
 public void Refresh(ResourceScreen resourceScreen, EntityOperationRequest<Resource> currentOperationRequest)
 {
     StateFilter = resourceScreen.StateFilterId;
     SelectedResourceType = _cacheService.GetResourceTypeById(resourceScreen.ResourceTypeId);
     RefreshSelectedResource(currentOperationRequest);
 }
コード例 #15
0
 private void OnSelectResourceCategoryExecuted(ResourceScreen obj)
 {
     ActivateResourceScreen(obj);
 }
コード例 #16
0
 private void ActivateResourceSearcher(ResourceScreen resourceScreen)
 {
     _resourceSearchViewModel.Refresh(resourceScreen, _currentOperationRequest);
     _regionManager.Regions[RegionNames.ResourceScreenRegion].Activate(_resourceSearchView);
 }
コード例 #17
0
        private void ActivateResourceScreen(ResourceScreen resourceScreen)
        {
            if (!_applicationState.IsLocked)
                _applicationStateSetter.SetSelectedResourceScreen(resourceScreen);

            if (resourceScreen != null)
            {
                if (resourceScreen.DisplayMode == 2)
                    ActivateResourceSearcher(resourceScreen);
                else if (resourceScreen.DisplayMode == 1)
                    ActivateDashboard(resourceScreen);
                else ActivateButtonSelector(resourceScreen);
            }

            RaisePropertyChanged(() => ResourceSwitcherButtons);
            ResourceSwitcherButtons.ForEach(x => x.Refresh());
        }
コード例 #18
0
        private void UpdateResourceScreenItems(ResourceScreen resourceScreen)
        {
            var stateFilter = resourceScreen.DisplayMode == 0 ? resourceScreen.StateFilterId : 0;
            var resourceData = GetResourceScreenItems(resourceScreen, stateFilter);
            if (ResourceScreenItems != null && (ResourceScreenItems.Count() == 0 || ResourceScreenItems.Count != resourceData.Count() || ResourceScreenItems.First().Name != resourceData.First().Name)) ResourceScreenItems = null;

            UpdateResourceButtons(resourceData);

            RaisePropertyChanged(() => ResourceScreenItems);
            RaisePropertyChanged(() => SelectedResourceScreen);
            RaisePropertyChanged(() => IsPageNavigatorVisible);
            RaisePropertyChanged(() => ScreenVerticalAlignment);
        }
コード例 #19
0
        public void UpdateResourceScreenItems(ResourceScreen resourceScreen, int pageNo)
        {
            if (resourceScreen == null) return;

            IEnumerable<int> set;
            if (resourceScreen.PageCount > 1)
            {
                set = resourceScreen.ScreenItems
                    .OrderBy(x => x.Order)
                    .Skip(pageNo * resourceScreen.ItemCountPerPage)
                    .Take(resourceScreen.ItemCountPerPage)
                    .Select(x => x.ResourceId);
            }
            else set = resourceScreen.ScreenItems.OrderBy(x => x.Order).Select(x => x.ResourceId);

            using (var w = WorkspaceFactory.CreateReadOnly())
            {
                var ids = w.Queryable<ResourceStateValue>().Where(x => set.Contains(x.ResoruceId)).GroupBy(x => x.ResoruceId).Select(x => x.Max(y => y.Id));
                var result = w.Queryable<ResourceStateValue>().Where(x => ids.Contains(x.Id)).Select(x => new { AccountId = x.ResoruceId, x.StateId });
                result.ToList().ForEach(x =>
                                            {
                                                var location = resourceScreen.ScreenItems.Single(y => y.ResourceId == x.AccountId);
                                                location.ResourceStateId = x.StateId;
                                            });
            }
        }
コード例 #20
0
 private void OnSelectResourceCategoryExecuted(ResourceScreen obj)
 {
     UpdateResourceScreenItems(obj);
 }
コード例 #21
0
 public void UpdateResourceScreen(ResourceScreen resourceScreen)
 {
     UpdateResourceScreenItems(resourceScreen, 0);
 }
コード例 #22
0
 public ResourceButtonViewModel(ResourceScreenItem model, ResourceScreen screen)
     : this(model, screen, null, false, true, null)
 {
 }
コード例 #23
0
 public ResourceSwitcherButtonViewModel(ResourceScreen model, IApplicationState applicationState, bool displayActiveScreen)
 {
     Model = model;
     _applicationState = applicationState;
     _displayActiveScreen = displayActiveScreen;
 }
コード例 #24
0
 public void Refresh(ResourceScreen resourceScreen, string stateFilter, EntityOperationRequest<Resource> currentOperationRequest)
 {
     StateFilter = stateFilter;
     _currentOperationRequest = currentOperationRequest;
     UpdateResourceScreenItems(resourceScreen);
 }
コード例 #25
0
        private void UpdateResourceScreenItems(ResourceScreen resourceScreen)
        {
            Feedback = "";
            var resourceData = _resourceService.GetCurrentResourceScreenItems(resourceScreen, CurrentPageNo).OrderBy(x => x.Order).ToList();

            if (ResourceScreenItems != null && (ResourceScreenItems.Count() == 0 || ResourceScreenItems.Count != resourceData.Count() || ResourceScreenItems.First().Caption != resourceData.First().Name)) ResourceScreenItems = null;

            if (ResourceScreenItems == null)
            {
                ResourceScreenItems = new ObservableCollection<IDiagram>();
                ResourceScreenItems.AddRange(resourceData.Select(x =>
                    new ResourceButtonViewModel(x,
                        SelectedResourceScreen,
                        ResourceSelectionCommand,
                        _currentOperationRequest.SelectedEntity != null,
                        _userService.IsUserPermittedFor(PermissionNames.MergeTickets), _cacheService.GetResourceStateById(x.ResourceStateId))));
            }
            else
            {
                for (var i = 0; i < resourceData.Count(); i++)
                {
                    var acs = ((ResourceButtonViewModel)ResourceScreenItems[i]).AccountState;
                    if (acs == null || acs.Id != resourceData.ElementAt(i).ResourceStateId)
                        ((ResourceButtonViewModel)ResourceScreenItems[i]).AccountState =
                            _cacheService.GetResourceStateById(resourceData.ElementAt(i).ResourceStateId);

                    ((ResourceButtonViewModel)ResourceScreenItems[i]).Model = resourceData.ElementAt(i);
                }
            }

            if (_currentOperationRequest.SelectedEntity != null)
            {
                FeedbackColor = "Red";
                FeedbackForeground = "White";
                Feedback = string.Format(Resources.SelectLocationThatYouWantToMoveTicket_f, _currentOperationRequest.SelectedEntity.Name);
            }
            else
            {
                FeedbackColor = "LightYellow";
                FeedbackForeground = "Black";
                Feedback = Resources.SelectLocationForOperation;
            }

            RaisePropertyChanged(() => ResourceScreenItems);
            RaisePropertyChanged(() => ResourceScreens);
            RaisePropertyChanged(() => SelectedResourceScreen);
            RaisePropertyChanged(() => IsPageNavigatorVisible);
            RaisePropertyChanged(() => ScreenVerticalAlignment);
        }
コード例 #26
0
 public void Refresh(ResourceScreen resourceScreen, EntityOperationRequest<Resource> currentOperationRequest)
 {
     SelectedResourceTemplate = _cacheService.GetResourceTemplateById(resourceScreen.ResourceTemplateId);
     RefreshSelectedResource(currentOperationRequest);
 }