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; }
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); }
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>(); }
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>(); }
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); }); } }
public ResourceScreen SetSelectedResourceScreen(ResourceScreen resourceScreen) { if (IsLocked && ActiveResourceScreen == null) ActiveResourceScreen = SelectedResourceScreen; else if (!IsLocked && ActiveResourceScreen != null) { resourceScreen = ActiveResourceScreen; ActiveResourceScreen = null; } SelectedResourceScreen = resourceScreen; return resourceScreen; }
public void SetSelectedResourceScreen(ResourceScreen resourceScreen) { SelectedResourceScreen = resourceScreen; }
protected override void BeforeEditSettings() { _resourceScreen = null; Settings.StateFilterNameValue.UpdateValues(_cacheService.GetStates(0).Select(x => x.Name)); }
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); }
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(); }
public void UpdateResourceScreenItems(ResourceScreen resourceScreen, int pageNo) { _resourceDao.UpdateResourceScreenItems(resourceScreen, pageNo); }
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(); }
public void Refresh(ResourceScreen resourceScreen, EntityOperationRequest<Resource> currentOperationRequest) { _currentOperationRequest = currentOperationRequest; UpdateResourceScreenItems(resourceScreen); }
public void Refresh(ResourceScreen resourceScreen, EntityOperationRequest<Resource> currentOperationRequest) { StateFilter = resourceScreen.StateFilterId; SelectedResourceType = _cacheService.GetResourceTypeById(resourceScreen.ResourceTypeId); RefreshSelectedResource(currentOperationRequest); }
private void OnSelectResourceCategoryExecuted(ResourceScreen obj) { ActivateResourceScreen(obj); }
private void ActivateResourceSearcher(ResourceScreen resourceScreen) { _resourceSearchViewModel.Refresh(resourceScreen, _currentOperationRequest); _regionManager.Regions[RegionNames.ResourceScreenRegion].Activate(_resourceSearchView); }
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()); }
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); }
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; }); } }
private void OnSelectResourceCategoryExecuted(ResourceScreen obj) { UpdateResourceScreenItems(obj); }
public void UpdateResourceScreen(ResourceScreen resourceScreen) { UpdateResourceScreenItems(resourceScreen, 0); }
public ResourceButtonViewModel(ResourceScreenItem model, ResourceScreen screen) : this(model, screen, null, false, true, null) { }
public ResourceSwitcherButtonViewModel(ResourceScreen model, IApplicationState applicationState, bool displayActiveScreen) { Model = model; _applicationState = applicationState; _displayActiveScreen = displayActiveScreen; }
public void Refresh(ResourceScreen resourceScreen, string stateFilter, EntityOperationRequest<Resource> currentOperationRequest) { StateFilter = stateFilter; _currentOperationRequest = currentOperationRequest; UpdateResourceScreenItems(resourceScreen); }
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); }
public void Refresh(ResourceScreen resourceScreen, EntityOperationRequest<Resource> currentOperationRequest) { SelectedResourceTemplate = _cacheService.GetResourceTemplateById(resourceScreen.ResourceTemplateId); RefreshSelectedResource(currentOperationRequest); }