Ejemplo n.º 1
1
        private void DataPortal_Fetch(FilterCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                this.RaiseListChangedEvents = false;
                this.IsReadOnly = false;

                IQueryable<Data.Filter> query = ctx.ObjectContext.Filters;

                if (criteria.FilterId != null)
                {
                    query = query.Where(row => row.FilterId == criteria.FilterId);
                }

                if (criteria.Name != null)
                {
                    query = query.Where(row => row.Name == criteria.Name);
                }

                if (criteria.Target != null)
                {
                    query = query.Where(row => row.Target == criteria.Target);
                }

                if (criteria.Query != null)
                {
                    query = query.Where(row => row.Query == criteria.Query);
                }

                if (criteria.CreatedBy != null)
                {
                    query = query.Where(row => row.CreatedBy == criteria.CreatedBy);
                }

                if (criteria.CreatedDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.CreatedDate >= criteria.CreatedDate.DateFrom);
                }

                if (criteria.CreatedDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.CreatedDate <= criteria.CreatedDate.DateTo);
                }

                if (criteria.SortBy != null)
                {
                    query = query.OrderBy(string.Format(
                        "{0} {1}",
                        criteria.SortBy,
                        criteria.SortOrder == ListSortDirection.Ascending ? "ASC" : "DESC"));
                }

                if (criteria.MaximumRecords != null)
                {
                    query = query.Take(criteria.MaximumRecords.Value);
                }

                var data = query.AsEnumerable().Select(FilterInfo.FetchFilterInfo);

                this.AddRange(data);

                this.IsReadOnly = true;
                this.RaiseListChangedEvents = true;
            }
        }
Ejemplo n.º 2
0
        // Temporary Set-up
        static DataManager()
        {
            FilterList = new FilterCriteria<Event>();
            FilterList.Add(new FilterCriterion<Event, string>((e) => e.Category, "CATEGORY"));
            FilterList.Add(new FilterCriterion<Event, string>((e) => e.Venue, "VENUE"));

            CategoryMetadata.Initialize();
        }
Ejemplo n.º 3
0
        internal static void DeleteFilter(FilterCriteria criteria)
        {
            var filter = Filter.FetchFilter(criteria);

            if (!Filter.CanDeleteObject(filter))
            {
                throw new SecurityException("Only the creator of the filter or users with full control can delete this filter");
            }

            Csla.DataPortal.Delete<Filter>(criteria);
        }
Ejemplo n.º 4
0
 private void ExecuteFetch(SqlConnection cn, FilterCriteria criteria)
 {
     using (var cm = cn.CreateCommand())
     {
         cm.CommandType = CommandType.StoredProcedure;
         cm.CommandText = "sp_SelectRoleAll";
         using (var dr = new SafeDataReader(cm.ExecuteReader()))
         {
             while (dr.Read())
             {
                 Add(Role.GetRoleEC(dr));
             }
         }
     } //using
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Create a Matching UI session to find matches for a resume or job that is already indexed
        /// </summary>
        /// <param name="sovClient">The SovrenClient</param>
        /// <param name="indexId">The index containing the document you want to match</param>
        /// <param name="documentId">The ID of the document to match</param>
        /// <param name="indexesToQuery">The indexes to find results in. These must all be of the same type (resumes or jobs)</param>
        /// <param name="preferredWeights">
        /// The preferred category weights for scoring the results. If none are provided,
        /// Sovren will determine the best values based on the source resume/job
        /// </param>
        /// <param name="filters">Any filters to apply prior to the match (a result must satisfy all the filters)</param>
        /// <param name="settings">Settings for this match</param>
        /// <param name="numResults">The number of results to show. If not specified, the default will be used.</param>
        /// <exception cref="SovrenException">Thrown when an API error occurs</exception>
        public static async Task <GenerateUIResponse> Match(
            this SovrenClientWithUI sovClient,
            string indexId,
            string documentId,
            IEnumerable <string> indexesToQuery,
            CategoryWeights preferredWeights = null,
            FilterCriteria filters           = null,
            SearchMatchSettings settings     = null,
            int numResults = 0)
        {
            MatchByDocumentIdOptions   options   = sovClient.InternalClient.CreateRequest(indexesToQuery, preferredWeights, filters, settings, numResults);
            UIMatchByDocumentIdOptions uiOptions = new UIMatchByDocumentIdOptions(options, sovClient.UISessionOptions);

            return(await sovClient.InternalClient.UIMatch(indexId, documentId, uiOptions));
        }
Ejemplo n.º 6
0
        public void InvalidPropertyNameError()
        {
            using (var container = new RhetosTestContainer())
            {
                var            repository = container.Resolve <Common.DomRepository>();
                var            childQuery = repository.TestGenericFilter.Child.Query();
                FilterCriteria filter;

                filter = new FilterCriteria {
                    Property = "Parentt", Operation = "equal", Value = null
                };
                TestUtility.ShouldFail <ClientException>(() => GenericFilterHelperFilter(childQuery, new[] { filter }).ToList(),
                                                         "generic filter", "property 'Parentt'", "TestGenericFilter", "Child'");
            }
        }
Ejemplo n.º 7
0
        public void TestCriteriaMatchingConvertedBeatmaps()
        {
            var exampleBeatmapInfo = getExampleBeatmap();
            var criteria           = new FilterCriteria
            {
                Ruleset = new RulesetInfo {
                    OnlineID = 6
                },
                AllowConvertedBeatmaps = true
            };
            var carouselItem = new CarouselBeatmap(exampleBeatmapInfo);

            carouselItem.Filter(criteria);
            Assert.IsFalse(carouselItem.Filtered.Value);
        }
Ejemplo n.º 8
0
        private void DataPortal_Fetch(FilterCriteria criteria)
        {
            RaiseListChangedEvents = false;
            IsReadOnly             = false;

            using (SqlConnection cn = new SqlConnection(Database.DB("Effie")))
            {
                cn.Open();

                ExecuteFetch(cn, criteria);
            }//using

            IsReadOnly             = true;
            RaiseListChangedEvents = true;
        }
Ejemplo n.º 9
0
        public override void Filter(FilterCriteria criteria)
        {
            base.Filter(criteria);

            bool match = criteria.Ruleset == null || Beatmap.RulesetID == criteria.Ruleset.ID || Beatmap.RulesetID == 0 && criteria.Ruleset.ID > 0 && criteria.AllowConvertedBeatmaps;

            if (!string.IsNullOrEmpty(criteria.SearchText))
            {
                match &=
                    Beatmap.Metadata.SearchableTerms.Any(term => term.IndexOf(criteria.SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0) ||
                    Beatmap.Version.IndexOf(criteria.SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0;
            }

            Filtered.Value = !match;
        }
        public override IEnumerable <User> Get(FilterCriteria criteria)
        {
            var users = _sqliteConnection
                        .GetAllWithChildren <User>()
                        .Skip(criteria.ItemsPerPage * criteria.Page)
                        .Take(criteria.ItemsPerPage)
                        .ToList();

            users.ForEach(us => {
                var userRole  = us.UserRoles.FirstOrDefault();
                userRole.Role = _sqliteConnection.GetWithChildren <Role>(userRole.RoleId);
            });

            return(users);
        }
Ejemplo n.º 11
0
        private void ExecuteFetch(SqlConnection cn, FilterCriteria criteria)
        {
            using (SqlCommand cm = cn.CreateCommand())
            {
                cm.CommandType = CommandType.StoredProcedure;
                cm.CommandText = "GetRegistrationList";
                cm.Parameters.AddWithValue("@SerialNo", criteria._serialNo);

                using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
                {
                    while (dr.Read())
                        this.Add(Registration.GetRegistration(dr));
                }
            }//using
        }
Ejemplo n.º 12
0
        private void DataPortal_Fetch(FilterCriteria criteria)
        {
            this.RaiseListChangedEvents = false;
            this.IsReadOnly             = false;
            if (criteria.set)
            {
                this.Add(new NameValuePair(-1, "ALL"));
            }

            this.Add(new NameValuePair(0, Resources.Female.ToString()));
            this.Add(new NameValuePair(1, Resources.Male.ToString()));
            this.IsReadOnly = true;

            this.RaiseListChangedEvents = true;
        }
Ejemplo n.º 13
0
        public void TestApplyDoubleConditionQueries()
        {
            const string query          = "give me maps with 6<stars<8 please";
            var          filterCriteria = new FilterCriteria();

            FilterQueryParser.ApplyQueries(filterCriteria, query);
            Assert.AreEqual("give me maps with  please", filterCriteria.SearchText.Trim());
            Assert.AreEqual(5, filterCriteria.SearchTerms.Length);
            Assert.IsNotNull(filterCriteria.StarDifficulty.Max);
            Assert.Greater(filterCriteria.StarDifficulty.Max, 7.99d);
            Assert.Less(filterCriteria.StarDifficulty.Max, 8.00d);
            Assert.IsNotNull(filterCriteria.StarDifficulty.Min);
            Assert.Greater(filterCriteria.StarDifficulty.Min, 6.00d);
            Assert.Less(filterCriteria.StarDifficulty.Min, 6.10d);
        }
Ejemplo n.º 14
0
        public async Task <HttpResult <List <User> > > GetUsers(FilterCriteria criteria, CancellationToken token = default(CancellationToken))
        {
            var result = new HttpResult <List <User> >();

            result.Data = _unitOfWork
                          .GetUsers(criteria)
                          .Select(us => new Models.User
            {
                Id        = us.Id,
                Username  = us.Username,
                FirstName = us.FirstName,
                LastName  = us.LastName,
                Email     = us.Email,
                Avatar    = us.Avatar,
                Role      = new Role
                {
                    Id   = us.Role.Id,
                    Name = us.Role.Name
                },
                Claims = us.Claims
                         .Select(cl => new Claim
                {
                    Type  = cl.Type,
                    Value = cl.Value
                })
                         .ToList(),
                CreatedAt = us.CreatedAt,
                CreatedBy = us.CreatedBy == null ? null : new User
                {
                    Id       = us.CreatedBy.Id,
                    Username = us.CreatedBy.Username
                },
                LastModifiedBy = us.LastModifiedBy == null ? null : new User
                {
                    Id       = us.LastModifiedBy.Id,
                    Username = us.LastModifiedBy.Username
                },
                LastModifiedAt = us.LastModifiedAt
            })
                          .ToList();

            if (result.Data == null)
            {
                result.Data = new List <User>();
            }

            return(result);
        }
Ejemplo n.º 15
0
        public PaginationGames FilterGames(FilterCriteria filters, int page, string size, string cultureCode)
        {
            _gamePipeline = new GamePipeline();
            var filterExpression = _gamePipeline.ApplyFilters(filters);

            IEnumerable <Game> games;
            int?maxSize = size != "ALL" ? (int?)int.Parse(size) : null;

            switch (filters.SortCriteria)
            {
            case SortCriteria.ByPriceAsc:
                games = _gameRepository.Get(filterExpression, x => x.Price, true, page, maxSize);
                break;

            case SortCriteria.ByPriceDesc:
                games = _gameRepository.Get(filterExpression, x => x.Price, false, page, maxSize);
                break;

            case SortCriteria.MostCommented:
                games = _gameRepository.Get(filterExpression, x => x.Comments.Count(), false, page, maxSize);
                break;

            case SortCriteria.New:
                games = _gameRepository.Get(filterExpression, x => x.GameInfo.UploadDate, false, page, maxSize);
                break;

            case SortCriteria.MostPopular:
                games = _gameRepository.Get(filterExpression, x => x.GameInfo.CountOfViews, false, page, maxSize);
                break;

            default:
                games = _gameRepository.Get(filterExpression, x => x.Id, true, page, maxSize);
                break;
            }

            var filteredGames = new PaginationGames()
            {
                Count = _gameRepository.GetCountObject(filterExpression),
                Games = games.ToList()
            };

            foreach (var game in filteredGames.Games)
            {
                LocalizationProvider.Localize(game, cultureCode);
            }

            return(filteredGames);
        }
Ejemplo n.º 16
0
        public static IQueryable <T> ApplyFilterRule <T>(IQueryable <T> data, FilterCriteria rule, Func <string, string, bool, Expression <Func <T, bool> > > filterFunctor)
        {
            if (rule == null || string.IsNullOrWhiteSpace(rule.ColumnName))
            {
                return(data);
            }

            Expression <Func <T, bool> > fnc = filterFunctor(rule.ColumnName, rule.FilterTerm, rule.IsExactMatch);

            if (fnc == null)
            {
                throw new ArgumentException("fnc");
            }

            return(data.Where(fnc));
        }
Ejemplo n.º 17
0
        private static void TestFilterByName(string expected, IEnumerable <C> items, string operation, object value)
        {
            var genericFilter = new FilterCriteria("Name", operation, value);

            Console.WriteLine("genericFilter: " + genericFilter.Property + " " + genericFilter.Operation + " " + genericFilter.Value);

            var genericFilterHelper = new GenericFilterHelper(new DomainObjectModelMock());
            var filterObject        = genericFilterHelper.ToFilterObjects(new FilterCriteria[] { genericFilter }).Single();

            Console.WriteLine("filterObject.FilterType: " + filterObject.FilterType.FullName);
            var filterExpression = genericFilterHelper.ToExpression <C>((IEnumerable <PropertyFilter>)filterObject.Parameter);

            var filteredItems = items.AsQueryable().Where(filterExpression).ToList();

            Assert.AreEqual(expected, TestUtility.DumpSorted(filteredItems, item => item.Name ?? "<null>"), "Testing '" + operation + " " + value + "'.");
        }
        private static string TestFilterByName(IEnumerable <C> items, string operation, object value)
        {
            var genericFilter = new FilterCriteria("Name", operation, value);

            Console.WriteLine("genericFilter: " + genericFilter.Property + " " + genericFilter.Operation + " " + genericFilter.Value);

            var genericFilterHelper = new GenericFilterHelper(new DomainObjectModelMock(), new DataStructureReadParametersStub());
            var filterObject        = genericFilterHelper.ToFilterObjects(typeof(C).FullName, new FilterCriteria[] { genericFilter }).Single();

            Console.WriteLine("filterObject.FilterType: " + filterObject.FilterType.FullName);
            var filterExpression = genericFilterHelper.ToExpression <C>((IEnumerable <PropertyFilter>)filterObject.Parameter);

            var filteredItems = items.AsQueryable().Where(filterExpression).ToList();

            return(TestUtility.DumpSorted(filteredItems, item => item.Name ?? "<null>"));
        }
Ejemplo n.º 19
0
 public object ProductsGloablSearching(FilterCriteria filterCritiria)
 {
     try
     {
         List <ProductsOfCategoryAppViewModel> ProductList = Mapper.Map <List <Product>, List <ProductsOfCategoryAppViewModel> >(_productBusiness.ProductsGlobalSearch(filterCritiria));
         if (ProductList.Count == 0)
         {
             throw new Exception(messages.NoItems);
         }
         return(JsonConvert.SerializeObject(new { Result = true, Records = ProductList }));
     }
     catch (Exception ex)
     {
         return(JsonConvert.SerializeObject(new { Result = false, Message = ex.Message }));
     }
 }
Ejemplo n.º 20
0
        public Stream SearchSchemaDate(string categoryUrl, string schemaUrl, string format, string searchField,
                                       string from, string to)
        {
            if (!_date_dd_mm_yyyy_Regex.IsMatch(from) || !_date_dd_mm_yyyy_Regex.IsMatch(to))
            {
                return(GetErrorStream("Invalid Date Format - needs to be in DD-MM-YYYY format", format));
            }

            var filter = new FilterCriteria {
                ColumnToSearch = searchField, From = from, To = to
            };

            return(SearchSchema(schemaUrl, format, filter));

            //return SearchSchema( schemaUrl, format, searchField, "", "", "", from, to);
        }
Ejemplo n.º 21
0
        public void TestCriteriaMatchingTerms(string terms, bool filtered)
        {
            var exampleBeatmapInfo = getExampleBeatmap();
            var criteria           = new FilterCriteria
            {
                Ruleset = new RulesetInfo {
                    OnlineID = 6
                },
                AllowConvertedBeatmaps = true,
                SearchText             = terms
            };
            var carouselItem = new CarouselBeatmap(exampleBeatmapInfo);

            carouselItem.Filter(criteria);
            Assert.AreEqual(filtered, carouselItem.Filtered.Value);
        }
Ejemplo n.º 22
0
        public List <Common.DTO.Product> GetProducts(FilterCriteria criteria)
        {
            var query = ProductRepository
                        .Entities
                        .Skip(criteria.Page * criteria.ItemsPerPage)
                        .Take(criteria.ItemsPerPage);

            if (!string.IsNullOrEmpty(criteria.Name))
            {
                query = query.Where(pt => pt.Name.Contains(criteria.Name));
            }

            return(query.OrderBy(pr => pr.Name)
                   .Select(_mapper.Map)
                   .ToList());
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = base.GetHashCode();
         hashCode = (hashCode * 397) ^ (_sharepointUtils != null ? _sharepointUtils.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ _indexCounter;
         hashCode = (hashCode * 397) ^ (FilterCriteria != null ? FilterCriteria.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ RequireAllCriteriaToMatch.GetHashCode();
         hashCode = (hashCode * 397) ^ (Result != null ? Result.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ SharepointServerResourceId.GetHashCode();
         hashCode = (hashCode * 397) ^ (SharepointList != null ? SharepointList.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ReadListItems != null ? ReadListItems.GetHashCode() : 0);
         return(hashCode);
     }
 }
Ejemplo n.º 24
0
 private void ExecuteFetch(SqlConnection cn, FilterCriteria criteria)
 {
     using (var cm = cn.CreateCommand())
     {
         cm.CommandType = CommandType.StoredProcedure;
         cm.CommandText = "sp_SelectUserClaimByfk_User";
         cm.Parameters.AddWithValue("@UserId", criteria.UserId);
         using (var dr = new SafeDataReader(cm.ExecuteReader()))
         {
             while (dr.Read())
             {
                 Add(UserClaim.GetUserClaimEC(dr));
             }
         }
     } //using
 }
Ejemplo n.º 25
0
 private void filterAlbumToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         FilterCriteria criteria = new FilterCriteria()
         {
             Artist = _song.Artist, Album = _song.Album
         };
         string json = JsonConvert.SerializeObject(criteria);
         tbSearch.Text = json;
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }
Ejemplo n.º 26
0
        public async Task <ActionResult <GrantListDTO> > FilterGrant([FromBody] FilterCriteria fc)
        {
            var grantList = await _context.Grant.OrderByDescending(q => q.StartDate).Include(g => g.Organization).ToListAsync();

            if (!string.IsNullOrEmpty(fc.Year))
            {
                if (fc.Year == "<- 1999")
                {
                    int year = 1999;
                    grantList = grantList.Where(grant => grant.StartDate.Year <= year).ToList();
                }
                else
                {
                    int year = Int32.Parse(fc.Year);
                    grantList = grantList.Where(grant => grant.StartDate.Year == year).ToList();
                }
            }

            if (fc.RegionId > 0)
            {
                grantList = (from grant in grantList
                             join grantregion in _context.GrantRegion
                             on grant.Id equals grantregion.GrantId
                             where grantregion.RegionId == fc.RegionId
                             select grant).ToList();
            }
            if (fc.TopicId > 0)
            {
                grantList = (from grant in grantList
                             join granttopic in _context.GrantTopic
                             on grant.Id equals granttopic.GrantId
                             join topic in _context.Topic
                             on granttopic.TopicId equals topic.Id
                             where topic.TopicGroupId == fc.TopicId
                             select grant).ToList();
            }

            var result = new GrantListDTO()
            {
                TotalAmount = (from grant in grantList
                               select grant.Amount).Sum(),
                TotalGrants = grantList.Count(),
                Grants      = grantList
            };

            return(result);
        }
        public async Task <GenericResponse <TokenResponseDto> > RefreshToken(string refresh_token)
        {
            //ServiceResult<UserBo> userResult = await GetUserFromAccessToken(refreshRequestDto.Access_Token);
            if (currentUserId <= 0)
            {
                return(GenericResponse <TokenResponseDto> .Error(ResultType.Error, "User not found into the token!", "U_RT_01", StatusCodes.Status404NotFound));
            }

            string access_token = serviceManager.serviceContext.Items["Token"].ToString();

            if (string.IsNullOrEmpty(access_token))
            {
                return(GenericResponse <TokenResponseDto> .Error(ResultType.Error, "Token not found into the request!", "U_RT_02", StatusCodes.Status404NotFound));
            }

            ServiceResult validationResult = await ValidateUserToken(currentUserId, access_token, refresh_token);

            if (!validationResult.Success)
            {
                return(GenericResponse <TokenResponseDto> .Error(ResultType.Error, validationResult.Error, "U_RT_03", StatusCodes.Status404NotFound));
            }

            UserBo         user           = null;
            FilterCriteria filterCriteria = new FilterCriteria();

            filterCriteria.QueryFilter       = "Id = " + this.currentUserId;
            filterCriteria.IncludeProperties = "UserType,UserRole,UserRole.Role,UserRole.Role.GrandRole";
            ServiceResult <IEnumerable <UserBo> > userResult = await serviceManager.User_Service.FindAsync(filterCriteria);

            if (!userResult.Success || userResult.Data == null)
            {
                return(GenericResponse <TokenResponseDto> .Error(ResultType.Error, "Logged user not found!", "U_RT_04", StatusCodes.Status404NotFound));
            }
            else
            {
                user = userResult.Data.FirstOrDefault();
            }

            ServiceResult <TokenResponseDto> userTokenResult = await GetTokenResponseAsync(user);

            if (!userTokenResult.Success)
            {
                return(GenericResponse <TokenResponseDto> .Error(ResultType.Error, userTokenResult.Error, "U_RT_05", StatusCodes.Status500InternalServerError));
            }

            return(GenericResponse <TokenResponseDto> .Ok(userTokenResult.Data));
        }
Ejemplo n.º 28
0
        public override void Filter(FilterCriteria criteria)
        {
            base.Filter(criteria);

            if (Beatmap.BeatmapSet?.Equals(criteria.SelectedBeatmapSet) == true)
            {
                // bypass filtering for selected beatmap
                Filtered.Value = false;
                return;
            }

            bool match =
                criteria.Ruleset == null ||
                Beatmap.RulesetID == criteria.Ruleset.ID ||
                (Beatmap.RulesetID == 0 && criteria.Ruleset.ID > 0 && criteria.AllowConvertedBeatmaps);

            match &= !criteria.StarDifficulty.HasFilter || criteria.StarDifficulty.IsInRange(Beatmap.StarDifficulty);
            match &= !criteria.ApproachRate.HasFilter || criteria.ApproachRate.IsInRange(Beatmap.BaseDifficulty.ApproachRate);
            match &= !criteria.DrainRate.HasFilter || criteria.DrainRate.IsInRange(Beatmap.BaseDifficulty.DrainRate);
            match &= !criteria.CircleSize.HasFilter || criteria.CircleSize.IsInRange(Beatmap.BaseDifficulty.CircleSize);
            match &= !criteria.Length.HasFilter || criteria.Length.IsInRange(Beatmap.Length);
            match &= !criteria.BPM.HasFilter || criteria.BPM.IsInRange(Beatmap.BPM);

            match &= !criteria.BeatDivisor.HasFilter || criteria.BeatDivisor.IsInRange(Beatmap.BeatDivisor);
            match &= !criteria.OnlineStatus.HasFilter || criteria.OnlineStatus.IsInRange(Beatmap.Status);

            match &= !criteria.Creator.HasFilter || criteria.Creator.Matches(Beatmap.Metadata.AuthorString);
            match &= !criteria.Artist.HasFilter || criteria.Artist.Matches(Beatmap.Metadata.Artist) ||
                     criteria.Artist.Matches(Beatmap.Metadata.ArtistUnicode);

            match &= !criteria.UserStarDifficulty.HasFilter || criteria.UserStarDifficulty.IsInRange(Beatmap.StarDifficulty);

            if (match)
            {
                var terms = new List <string>();

                terms.AddRange(Beatmap.Metadata.SearchableTerms);
                terms.Add(Beatmap.Version);

                foreach (var criteriaTerm in criteria.SearchTerms)
                {
                    match &= terms.Any(term => term.IndexOf(criteriaTerm, StringComparison.InvariantCultureIgnoreCase) >= 0);
                }
            }

            Filtered.Value = !match;
        }
 private void GetExcludedNestedGroups(List <IdentityStoreObject> expiringGroups, List <string> identities)
 {
     if ((expiringGroups == null ? false : expiringGroups.Count > 0))
     {
         List <IdentityStoreObject> smartGroups     = new List <IdentityStoreObject>();
         List <IdentityStoreObject> parentDynasties = new List <IdentityStoreObject>();
         this.FilterGroups(expiringGroups, smartGroups, 1);
         this.FilterGroups(expiringGroups, parentDynasties, 2);
         FilterCriteria nestGroupsFilterCriteria = this.PrepareNestChildsCriteria(smartGroups);
         if ((nestGroupsFilterCriteria.get_Child() == null ? false : nestGroupsFilterCriteria.get_Child().Count > 0))
         {
             SearchFilter searchFilter1 = new SearchFilter();
             searchFilter1.set_ExtensionDataCriteria(nestGroupsFilterCriteria);
             searchFilter1.set_ProviderCriteria(new FilterCriteria());
             SearchFilter searchFilter = searchFilter1;
             int          totalFound   = 0;
             ServicesSearchServiceClient searchServiceClient  = new ServicesSearchServiceClient(false);
             List <IdentityStoreObject>  expiringNestedGroups = searchServiceClient.SearchEx(Helper.CurrentTask.get_IdentityStoreId(), 2, ref totalFound, searchFilter, new Dictionary <string, bool>(), string.Empty, 1, -1, 20000, this.GetAttributesToLoad(), false);
             if ((expiringNestedGroups == null ? false : expiringNestedGroups.Count > 0))
             {
                 List <string> strs = new List <string>();
                 expiringNestedGroups.ForEach((IdentityStoreObject grp) => {
                     if (!expiringGroups.Any <IdentityStoreObject>((IdentityStoreObject expGrp) => expGrp.get_ObjectIdFromIdentityStore().Equals(grp.get_ObjectIdFromIdentityStore(), StringComparison.InvariantCultureIgnoreCase)))
                     {
                         strs.Add(grp.get_ObjectIdFromIdentityStore());
                     }
                 });
                 identities.AddRange(strs);
             }
         }
         if ((parentDynasties == null ? false : parentDynasties.Count > 0))
         {
             List <IdentityStoreObject> allLevelCurrentChildGroups = this.EnsureChildGroups(Helper.CurrentTask.get_IdentityStoreId(), new ServicesGroupServiceClient(false), parentDynasties);
             if ((allLevelCurrentChildGroups == null ? false : allLevelCurrentChildGroups.Count > 0))
             {
                 List <string> strs1 = new List <string>();
                 allLevelCurrentChildGroups.ForEach((IdentityStoreObject grp) => {
                     if (!expiringGroups.Any <IdentityStoreObject>((IdentityStoreObject expGrp) => expGrp.get_ObjectIdFromIdentityStore().Equals(grp.get_ObjectIdFromIdentityStore(), StringComparison.InvariantCultureIgnoreCase)))
                     {
                         strs1.Add(grp.get_ObjectIdFromIdentityStore());
                     }
                 });
                 identities.AddRange(strs1);
             }
         }
     }
 }
Ejemplo n.º 30
0
        public void TestCriteriaMatchingArtistWithNullUnicodeName(string artistName, bool filtered)
        {
            var exampleBeatmapInfo = getExampleBeatmap();

            exampleBeatmapInfo.Metadata.ArtistUnicode = string.Empty;

            var criteria = new FilterCriteria
            {
                Artist = new FilterCriteria.OptionalTextFilter {
                    SearchTerm = artistName
                }
            };
            var carouselItem = new CarouselBeatmap(exampleBeatmapInfo);

            carouselItem.Filter(criteria);
            Assert.AreEqual(filtered, carouselItem.Filtered.Value);
        }
Ejemplo n.º 31
0
        private Stream SearchSchema(string schemaUrl, string format, FilterCriteria filterCriteria)
        {
            var dataSetSchemaService = ObjectFactory.GetInstance <IDataSetSchemaService>();
            var schema = dataSetSchemaService.Repository.GetQuery()
                         .Include(s => s.Category)
                         .Include(s => s.Definition.Columns).ToList()
                         .FirstOrDefault(c => c.FriendlyUrl == schemaUrl);

            if (schema == null)
            {
                return(GetErrorStream("This data is not available", format));
            }


            if (!schema.IsOnline)
            {
                return(GetErrorStream("This data is not available", format));
            }


            var filter = new List <FilterCriteria> {
                filterCriteria
            };

            var datasetdetailservice = ObjectFactory.GetInstance <IDataSetDetailService>();
            var result = datasetdetailservice.SearchSchema(filter, schema, -1, -1, filterCriteria.ColumnToSearch, "ASC",
                                                           false);

            if (result.Count == 0)
            {
                return(GetErrorStream("No matching records found", format));
            }


            if (result.Count > 10000)
            {
                return
                    (GetErrorStream(
                         result.Count +
                         " records were returned. The maximum the api allows is 10000. Please change the search criteria to return less records.",
                         format));
            }


            return(GetDataTableStream(result.Data, format));
        }
Ejemplo n.º 32
0
        private void ExecuteFetch(SqlConnection cn, FilterCriteria criteria)
        {
            using (SqlCommand cm = cn.CreateCommand())
            {
                cm.CommandType = CommandType.StoredProcedure;
                cm.CommandText = "GetAdministratorList";


                using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
                {
                    while (dr.Read())
                    {
                        this.Add(Administrator.GetAdministrator(dr));
                    }
                }
            }//using
        }
Ejemplo n.º 33
0
        private void ExecuteFetch(SqlConnection cn, FilterCriteria criteria)
        {
            using (SqlCommand cm = cn.CreateCommand())
            {
                cm.CommandType = CommandType.StoredProcedure;
                cm.CommandText = "GetJuryRemarksList";

                cm.Parameters.AddWithValue("@JuryId", criteria.JuryId);
                using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
                {
                    while (dr.Read())
                    {
                        this.Add(JuryRemarks.GetJuryRemarks(dr));
                    }
                }
            }//using
        }
Ejemplo n.º 34
0
        private void bttSearch_Click(object sender, EventArgs e)
        {
            Dictionary<string,FilterCriteria> mDictionary = new Dictionary<string, FilterCriteria>
            {
                {"None",FilterCriteria.None} ,{"An Documentatie",FilterCriteria.An},{ "Nr. Documentatie", FilterCriteria.NrDoc},
                { "Nume Beneficiar",FilterCriteria.NumeBeneficiar},{ "C.N.P. Beneficiar",FilterCriteria.CnpBeneficiar},
                { "Cod Documentatie",FilterCriteria.TipDoc},{ "Nr. Contract",FilterCriteria.NrContract},{"U.A.T.",FilterCriteria.Uat},
                { "Receptionate",FilterCriteria.Receptionata},{ "Respinse",FilterCriteria.Respinsa}, {"In Lucru",FilterCriteria.InLucru}};

            FilterForm sel = FilterForm.GetCautaForm(mDictionary);
            var result = sel.ShowDialog();
            if (result != DialogResult.OK) return;
             _filterKeyWordS = sel.SearchKey;
               // if (string.IsNullOrEmpty(_filterKeyWordS)) return;
            _filter = sel.FilterCriteria;
            FillGridView(_filter, _filterKeyWordS);
            if (IsFilterd())
            {
                lblFilter.Text = @"Filter On";
                lblFilter.Font = new System.Drawing.Font(lblFilter.Font, System.Drawing.FontStyle.Bold);
            }
            else
            {
                lblFilter.Text = "";
            }
        }
Ejemplo n.º 35
0
        private void FillGridView(FilterCriteria criteria, string key)
        {
            try
            {
                ContaContext conta = new ContaContext();
                UnitOfWork unityOfWork = new UnitOfWork(conta);

                BindingSource bindingSource;

                #region Switch
                switch (criteria)
                {
                    case FilterCriteria.An:

                        try
                        {
                            int year = int.Parse(key);
                            bindingSource = new BindingSource
                            {
                                DataSource = unityOfWork.Contracte.GetGridViewContractByYear(year)
                            };
                        }
                        catch (Exception)
                        {
                            return;
                        }
                        break;

                    case FilterCriteria.NrContract:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Contracte.GetContractByNumber(key) };
                        break;

                    case FilterCriteria.Suma:
                        try
                        {
                            decimal value = decimal.Parse(key);
                            bindingSource = new BindingSource{ DataSource = unityOfWork.Contracte.GetContractByAmount(value) };
                        }
                        catch (Exception)
                        {
                            return;
                        }

                        break;

                    case FilterCriteria.NumeBeneficiar:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Contracte.GetContractByBeneficiar(key) };
                        break;

                    default:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Contracte.GetContracts() };
                        break;
                }
                #endregion Switch

                // ReSharper disable once ConstantConditionalAccessQualifier
                if (bindingSource?.DataSource == null) return;
                gridViewContract.DataSource = bindingSource;
                if (gridViewContract.Columns["ContractId"] == null)
                {
                    gridViewContract.Rows.Clear();
                    gridViewContract.Refresh();
                    var dataGridViewColumn = gridViewContract.Columns["Current"];
                    if (dataGridViewColumn != null) dataGridViewColumn.Visible = false;
                }
                else
                {
                    var dataGridViewColumn = gridViewContract.Columns["ContractId"];
                    dataGridViewColumn.Visible = false;
                    gridViewContract.Columns[1].MinimumWidth = 100;
                    gridViewContract.Columns[2].MinimumWidth = 150;
                    gridViewContract.Columns[3].MinimumWidth = 300;
                    gridViewContract.Columns[4].MinimumWidth = 120;
                    gridViewContract.Columns[5].MinimumWidth = 500;
                    gridViewContract.Columns[6].MinimumWidth = 350;
                }
            }
            catch (InvalidOperationException ex) { MessageBox.Show(ex.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
Ejemplo n.º 36
0
        private void bttSearchContract_Click(object sender, EventArgs e)
        {
            Dictionary<string, FilterCriteria> mDictionary = new Dictionary<string, FilterCriteria>()
            {
                {"None",FilterCriteria.None}, {"Nr. Contract",FilterCriteria.NrContract}, {"An Contract", FilterCriteria.An },
                { "Nume Beneficiar",FilterCriteria.NumeBeneficiar },{"Valoare Contract",FilterCriteria.Suma }
            };

            FilterForm sel = FilterForm.GetCautaForm(mDictionary);
            var result = sel.ShowDialog();
            if (result != DialogResult.OK) return;
            _filterKeyWordS = sel.SearchKey;
            //if (string.IsNullOrEmpty(key)) return;
            _filter = sel.FilterCriteria;
            FillGridView(_filter, _filterKeyWordS);

            if (IsFilterd())
            {
                lblFilter.Text = @"Filter On";
                lblFilter.Font = new System.Drawing.Font(lblFilter.Font, System.Drawing.FontStyle.Bold);
            }
            else
            {
                lblFilter.Text = "";
            }
        }
Ejemplo n.º 37
0
        private void FillGridView(FilterCriteria criteria, string key)
        {
            try
            {
                ContaContext conta = new ContaContext();
                UnitOfWork unityOfWork = new UnitOfWork(conta);

                BindingSource bindingSource;

                #region Switch
                switch (criteria)
                {
                    case FilterCriteria.An:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Lucrari.GetLucrariByYear(key) };
                        break;
                    case FilterCriteria.CnpBeneficiar:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Lucrari.GetLucrariByBeneficiarName(key) };
                        break;
                    case FilterCriteria.NrContract:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Lucrari.GetLucrareByContract(key) };
                        break;
                    case FilterCriteria.NrDoc:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Lucrari.GetLucrariByNrDocumentatie(key) };
                        break;
                    case FilterCriteria.NumeBeneficiar:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Lucrari.GetLucrariByBeneficiarName(key) };
                        break;

                    case FilterCriteria.TipDoc:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Lucrari.GetLucrariByCodLucrare(key) };
                        break;
                    case FilterCriteria.Uat:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Lucrari.GetLucrariByUat(key) };
                        break;
                    case FilterCriteria.Receptionata:
                    case FilterCriteria.Respinsa:
                    case FilterCriteria.InLucru:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Lucrari.GetLucrariByStatusOcpi(key) };
                        break;

                    default:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Lucrari.GetLucrari() };
                        break;
                }
                #endregion Switch

                // ReSharper disable once ConstantConditionalAccessQualifier
                if (bindingSource?.DataSource == null) return;
                LucrariView.DataSource = bindingSource;
                if (LucrariView.Columns["LucrareId"] == null)
                {
                    LucrariView.Rows.Clear();
                    LucrariView.Refresh();
                    var dataGridViewColumn = LucrariView.Columns["Current"];
                    if (dataGridViewColumn != null) dataGridViewColumn.Visible = false;
                }
                else
                {
                    var dataGridViewColumn = LucrariView.Columns["LucrareId"];
                    dataGridViewColumn.Visible = false;
                }
            }
            catch (InvalidOperationException ex) { MessageBox.Show(ex.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
Ejemplo n.º 38
0
 internal static FilterInfoList FilterFetchInfoList(FilterCriteria criteria)
 {
     return FilterInfoList.FetchFilterInfoList(criteria);
 }
Ejemplo n.º 39
0
        private void DataPortal_Fetch(FilterCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                IQueryable<Data.Filter> query = ctx.ObjectContext.Filters;

                if (criteria.FilterId != null)
                {
                    query = query.Where(row => row.FilterId == criteria.FilterId);
                }

                var data = query.Single();

                this.Fetch(data);

                this.BusinessRules.CheckRules();
            }
        }
Ejemplo n.º 40
0
        private void DataPortal_Delete(FilterCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                var data = ctx.ObjectContext.Filters
                    .Single(row => row.FilterId == criteria.FilterId);

                ctx.ObjectContext.Filters.DeleteObject(data);

                ctx.ObjectContext.SaveChanges();
            }
        }
        [HttpPost]//Örneğin İki Tarih Arası İStenirse bunu bir attribute ile meta dataya göm ve sayı tarih vb tüm alanlar için Kullan.
        public virtual MvcResult<object> Search(SearchRequest request, int? take, int? page, SearchSortRequest[] sort)//Button Edit Search. Ek paramatreler kendo dan.
        {
            return this.ResultList(() =>
            {
                Datas<object> ret = new Datas<object>();

                Type entityType = null;
               // CacheMetaDataConfig.MetaData.TryGetType(request.TypeFullName, out entityType);
                if (null == entityType)
                    throw  new NullReferenceException(request.TypeFullName);

                object entity = JsonConvert.DeserializeObject(request.EntityJson, entityType);
                IEntityMetaData metaData = new MetaDataProvider().CreateEntityMetaData(entityType);

                ISqlQueryProvider builder = entity as ISqlQueryProvider; ;

                if (null == builder)
                {
                    builder = new SqlQueryBuilderSelect(metaData);
                }

                const char prefix = ':';
                FilterCriteriaList criteriaList = new FilterCriteriaList(prefix);
                HashSet<string> betweenColumns = new HashSet<string>();
                IEnumerable<BetweenAttribute> bas = entityType.GetCustomAttributes<BetweenAttribute>();
                if (!bas.IsEmptyList())
                {
                    foreach (BetweenAttribute ba in bas)
                    {
                        betweenColumns.Add(ba.FirstProperty);
                        betweenColumns.Add(ba.SecondProperty);

                        betweenColumns.Add(ba.ColumnName); //?

                    object firstVal = entityType.GetProperty(ba.FirstProperty).GetValue(entity);
                        if (!firstVal.IsNull())
                        {
                            object secVal = entityType.GetProperty(ba.SecondProperty).GetValue(entity);
                            if (secVal.IsNull())
                                secVal = firstVal;

                            FilterCriteria criteria = new FilterCriteria(ba.ColumnName, ConditionOperator.Between,  prefix, firstVal, secVal);
                            criteriaList.Add(criteria);
                        }
                    }
                }


                SqlQuery query = builder.ToQuery().ToInnerQuery();
                foreach (PropertyMetaData pmd in metaData.Properties)
                {
                    if (betweenColumns.Contains(pmd.Schema.ColumnName)) continue;

                    PropertyInfo pi = pmd.Property;

                    object entityValue = pi.GetValue(entity);
                    if (null != entityValue && entityValue.ToString().Length != 0)
                    {
                        object defaultValue = MvcExtensions.GetSearchDefaultValue(pi.PropertyType);
                        if (!Object.Equals(defaultValue, entityValue))//Kullanıcı Değer Girdi İse.
                        {
                            FilterCriteria criteria = null;
                            Type propertyType = pi.PropertyType;
                            if (propertyType == CachedTypes.String)
                            {
                                criteria = new FilterCriteria(pi.Name, ConditionOperator.Contains, prefix, entityValue);
                            }
                            else
                            {
                                criteria = new FilterCriteria(pi.Name, ConditionOperator.Equals, prefix, entityValue);
                            }

                            criteriaList.Add(criteria);
                        }
                    }
                }

                if (!request.CustomFilters.IsEmptyList())
                {
                    foreach(CustomFilter filter in request.CustomFilters)
                    {
                        FilterCriteria criteria = filter.ToCriteria(prefix);
                        if (null != criteria)
                        {
                            criteriaList.Add(filter.ToCriteria(prefix));
                        }
                    }
                }

                if (criteriaList.Count != 0)
                {
                    query.Combine(criteriaList.ToQuery("T."));
                }

                SqlQuery nonPagingQuery = query;
                bool pagingEnabled = take.HasValue && page.HasValue;
                if (pagingEnabled)//Yani Sayfalama var ise ???....
                {
                    if (sort.IsEmptyList())
                    {
                        PropertyMetaData pm = metaData.Properties.FirstOrDefault((p) => p.Schema.IsKey);
                        if (null == pm)//Hiç pk yok ise.
                        {
                            pm = metaData.Properties.First();
                        }

                        sort = new [] { new SearchSortRequest() { Field = pm.Schema.ColumnName, Dir = "asc"} };
                    }

                    var fp = this.CreateFluentPaging();

                    fp.Select("*")
                        .From("(" + query + ") TP")
                        .OrderBy(sort.First().Field + " "  + sort.First().Dir)
                        .Page(page.Value)
                        .Take(take.Value);

                    SqlQuery temp = fp.ToQuery();
                    query.Parameters.ForEach((p) =>
                    {
                        temp.Parameters.Add(p);
                    });

                    query = temp;
                }

                ret.EntityList =  (IEnumerable<object>)base.Cmd.Query(entityType, query);

                if (pagingEnabled)
                {
                    SqlQuery countQuery = "SELECT COUNT(*) FROM ( ".ToQuery();
                    countQuery.Combine(nonPagingQuery);
                    countQuery.Sql(" ) T");

                    ret.Total = base.Cmd.Factory.DataAccess.ExecuteScalarSafely<int>(countQuery);
                }

                return ret;
            });
        }
        public SqlQuery GenerateWhereQuery()
        {
            SqlQuery query = new SqlQuery();
            StringBuilder text = query.Text;
            text.AppendLine();
            text.Append("where ");
            FilterCriteriaList criteriaList = new FilterCriteriaList('@');
            foreach (KeyValuePair<PropertyInfo, WebControl> kvp in this.SearchControls)
            {
                string value = GetControlValue(kvp.Value);
                if (value.Length != 0)
                {
                    PropertyInfo pi = kvp.Key;

                    if (!pi.NotMapped())
                    {
                        ConditionOperator op = (ConditionOperator)Int32.Parse(this.FilterComboBoxes[pi].SelectedValue);

                        FilterCriteria criteria = new FilterCriteria(pi.GetColumnName(), op, '@', value);

                        criteriaList.Add(criteria);
                    }
                }
            }
            if (criteriaList.Count != 0)
            {
                return criteriaList.ToQuery(DynamicSearchPage.TableAlias + '.');
            }
            else
                return new SqlQuery();
        }
Ejemplo n.º 43
0
 internal static FilterInfoList FetchFilterInfoList(FilterCriteria criteria)
 {
     return Csla.DataPortal.Fetch<FilterInfoList>(criteria);
 }
Ejemplo n.º 44
0
 internal static Filter FetchFilter(FilterCriteria criteria)
 {
     return Csla.DataPortal.Fetch<Filter>(criteria);
 }