public List<Resource> FindResources(ResourceType resourceType, string searchString, string stateFilter) { var templateId = resourceType != null ? resourceType.Id : 0; var searchValue = searchString.ToLower(); using (var w = WorkspaceFactory.CreateReadOnly()) { var result = w.Query<Resource>( x => x.ResourceTypeId == templateId && (x.CustomData.Contains(searchString) || x.Name.ToLower().Contains(searchValue))).Take(250).ToList(); if (resourceType != null) result = result.Where(x => resourceType.GetMatchingFields(x, searchString).Any(y => !y.Hidden) || x.Name.ToLower().Contains(searchValue)).ToList(); if (!string.IsNullOrEmpty(stateFilter)) { var sv = string.Format("\"S\":\"{0}\"", stateFilter); var set = result.Select(x => x.Id).ToList(); var ids = w.Queryable<ResourceStateValue>().Where(x => set.Contains(x.ResoruceId) && x.ResourceStates.Contains(sv)).GroupBy(x => x.ResoruceId).Select(x => x.Max(y => y.Id)); var resourceIds = w.Queryable<ResourceStateValue>().Where(x => ids.Contains(x.Id)).Select(x => x.ResoruceId).ToList(); result = result.Where(x => resourceIds.Contains(x.Id)).ToList(); } return result; } }
public List<Resource> SearchResources(string searchString, ResourceType selectedResourceType, string stateFilter) { return _resourceDao.FindResources(selectedResourceType, searchString, stateFilter); }
public List<Resource> SearchResources(string searchString, ResourceType selectedResourceType, int stateFilter) { var templateId = selectedResourceType != null ? selectedResourceType.Id : 0; var searchValue = searchString.ToLower(); using (var w = WorkspaceFactory.CreateReadOnly()) { var result = w.Query<Resource>( x => x.ResourceTypeId == templateId && (x.CustomData.Contains(searchString) || x.Name.ToLower().Contains(searchValue))).Take(250).ToList(); if (selectedResourceType != null) result = result.Where(x => selectedResourceType.GetMatchingFields(x, searchString).Any(y => !y.Hidden) || x.Name.ToLower().Contains(searchValue)).ToList(); if (stateFilter > 0) { var set = result.Select(x => x.Id).ToList(); var ids = w.Queryable<ResourceStateValue>().Where(x => set.Contains(x.ResoruceId) && x.StateId == stateFilter).GroupBy(x => x.ResoruceId).Select(x => x.Max(y => y.Id)); var resourceIds = w.Queryable<ResourceStateValue>().Where(x => ids.Contains(x.Id)).Select(x => x.ResoruceId).ToList(); result = result.Where(x => resourceIds.Contains(x.Id)).ToList(); } return result; } }
private void OnSelectResource(ResourceType obj) { var ticketResource = SelectedTicket.TicketResources.SingleOrDefault(x => x.ResourceTypeId == obj.Id); var selectedResource = ticketResource != null ? _cacheService.GetResourceById(ticketResource.ResourceId) : Resource.GetNullResource(obj.Id); EntityOperationRequest<Resource>.Publish(selectedResource, EventTopicNames.SelectResource, EventTopicNames.ResourceSelected); }
private bool CanSelectResource(ResourceType arg) { return !SelectedTicket.Locked && SelectedTicket.CanSubmit && _cacheService.GetResourceScreens().Any(x => x.ResourceTypeId == arg.Id); }
public ResourceSearchResultViewModel(Resource model, ResourceType template) { ResourceType = template; Model = model; }
public ResourceCustomDataViewModel(Resource model, ResourceType template) { _template = template; Model = model; }
public ResourceButton(ResourceType model, Ticket selectedTicket) { _selectedTicket = selectedTicket; Model = model; }
private bool CanSelectResource(ResourceType arg) { return !SelectedTicket.IsLocked && SelectedTicket.CanSubmit && _applicationState.GetTicketResourceScreens().Any(x => x.ResourceTypeId == arg.Id); }