コード例 #1
0
ファイル: ResourceDao.cs プロジェクト: neapolis/SambaPOS-3
        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;
            }
        }
コード例 #2
0
 public List<Resource> SearchResources(string searchString, ResourceType selectedResourceType, string stateFilter)
 {
     return _resourceDao.FindResources(selectedResourceType, searchString, stateFilter);
 }
コード例 #3
0
        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;
            }
        }
コード例 #4
0
 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);
 }
コード例 #5
0
 private bool CanSelectResource(ResourceType arg)
 {
     return !SelectedTicket.Locked && SelectedTicket.CanSubmit && _cacheService.GetResourceScreens().Any(x => x.ResourceTypeId == arg.Id);
 }
コード例 #6
0
 public ResourceSearchResultViewModel(Resource model, ResourceType template)
 {
     ResourceType = template;
     Model = model;
 }
コード例 #7
0
 public ResourceCustomDataViewModel(Resource model, ResourceType template)
 {
     _template = template;
     Model = model;
 }
コード例 #8
0
ファイル: ResourceButton.cs プロジェクト: Spanky81/SambaPOS-3
 public ResourceButton(ResourceType model, Ticket selectedTicket)
 {
     _selectedTicket = selectedTicket;
     Model = model;
 }
コード例 #9
0
 private bool CanSelectResource(ResourceType arg)
 {
     return !SelectedTicket.IsLocked && SelectedTicket.CanSubmit && _applicationState.GetTicketResourceScreens().Any(x => x.ResourceTypeId == arg.Id);
 }