예제 #1
0
        public static string GetPredicateByFilter(this Filtration filter, Type propertyType)
        {
            filter.ConvertFilter();

            var predicate = $"x => x.{filter.ColumnName}";

            if (propertyType == typeof(int) ||
                propertyType == typeof(long) ||
                propertyType == typeof(decimal) ||
                propertyType == typeof(double) ||
                propertyType == typeof(float))
            {
                if (string.IsNullOrEmpty(filter.ColumnOperator))
                {
                    return($"{predicate}=={filter.ColumnValue}");
                }

                return(filter.ColumnOperator == "="
                    ? $"{predicate}=={filter.ColumnValue}"
                    : $"{predicate}{filter.ColumnOperator}{filter.ColumnValue}");
            }

            if (propertyType == typeof(string))
            {
                return(predicate + $@".ToLower().Contains(""{filter.ColumnValue}"")");
            }

            if (propertyType == typeof(DateTime))
            {
                return(predicate + $@".ToShortDateString() == {filter.ColumnValue}");
            }

            return("x => true");
        }
예제 #2
0
        private static void ConvertFilter(this Filtration filter)
        {
            filter.ColumnName = filter.ColumnName.First().ToString().ToUpper()
                                + filter.ColumnName.Substring(1);

            filter.ColumnValue = filter.ColumnValue.ToLower();
        }
예제 #3
0
        static void Main(string[] args)
        {
            Dog jony = new Dog()
            {
                Name = "Jony", Id = 2, Color = "black"
            };
            Dog mike = new Dog()
            {
                Name = "mike", Id = 5, Color = "white"
            };
            Dog persi = new Dog()
            {
                Name = "persi", Id = 12, Color = "brown"
            };
            Dog jecky = new Dog()
            {
                Name = "Jecky", Id = -2, Color = "black/white"
            };
            Dog suzi = new Dog()
            {
                Name = "S", Id = 15, Color = "red/white/brown"
            };

            Filtration.DogFiltration(jony);
            Filtration.DogFiltration(mike);
            Filtration.DogFiltration(persi);
            Filtration.DogFiltration(jecky);
            Filtration.DogFiltration(suzi);

            DogShelterDB.PrintAll(DogShelterDB.ListOfDogs);

            Console.ReadKey();
        }
예제 #4
0
        public DescriptiveResponse <UserDTO> FilterUsers(Filtration filter)
        {
            // Find all items that match filteration
            Read.User user = _readRepository.Find(filter).Collection.FirstOrDefault();

            var userDTO = UserMapper.Instance.ToDTOObject(user);

            // Return success response
            return(DescriptiveResponse <UserDTO> .Success(userDTO));
        }
        public FilteredCollection <TEntity> Find(Filtration filter)
        {
            // Append filterCriteria to collection
            IEnumerable <TEntity> collection = _context.Set <TEntity>().AppendFilterCriteria <TEntity, TId>(filter).AsEnumerable();

            return(new FilteredCollection <TEntity>
            {
                Collection = collection,
                TotalCount = Count(filter)
            });
        }
        private async void PrescribedMedParameter()
        {
            filterBy = Filtration.PrescribedMedication;

            //send the filter info the the medicationviewmodel class
            MessagingCenter.Send(this, MessagingKeys.Filter, filterBy);

            //wait for the view to be sort before pop async execution
            await Task.Delay(1000);

            await PopupNavigation.Instance.PopAsync(true);
        }
        private async void SelfPrescribed()
        {
            filterBy = Filtration.SelfPrescribed;

            //send the filter info the medicationviewmodel class
            MessagingCenter.Send(this, MessagingKeys.Filter, filterBy);

            //wait for the view to be sort before pop async execution
            await Task.Delay(1000);

            //go back to medication history page
            await PopupNavigation.Instance.PopAllAsync(true);
        }
예제 #8
0
        public static void Main(string[] args)
        {
            List <Thread> threadList = new List <Thread>();
            //Inicjalizacja warzelni
            BrewingVat      kadzWarzelna1      = new BrewingVat(1000);
            FermentationVat kadzFermentacyjna1 = new FermentationVat(3000);
            Bottler         rozlewnia          = new Bottler(1000);
            Warehouse       magazyn            = new Warehouse(7000);
            Filtration      kadzFiltracyjna    = new Filtration();
            SuperVisor      superVisor         = new SuperVisor(rozlewnia, kadzWarzelna1, kadzFermentacyjna1, magazyn, kadzFiltracyjna);

            Thread fred1 = new Thread(new ThreadStart(superVisor.Run));

            fred1.Start();
        }
        /// <inheritdoc />
        public virtual IReadOnlyCollection <ConfigurationValidationError> Validate(string?prefix = null)
        {
            var errors = new ConfigurationValidationErrorCollection(prefix);

            errors.AddErrorIf(String.IsNullOrWhiteSpace(Name), nameof(Name), " не должно быть пустым");
            errors.AddErrorIf(EventsPeriodicCheckSec < 0, nameof(EventsPeriodicCheckSec), String.Format(ShouldBeEqualOrGreaterThanMask, 0));
            errors.AddErrorIf(WorkersCount <= 0, nameof(WorkersCount), String.Format(ShouldBeEqualOrGreaterThanMask, 1));
            errors.AddErrorIf(StateFlushPeriodSec <= 0, nameof(StateFlushPeriodSec), String.Format(ShouldBeEqualOrGreaterThanMask, 1));

            if (Filtration != null !)
            {
                errors.AddErrors(Filtration.Validate($"{nameof(Filtration)}"));
            }

            return(errors);
        }
        public int Count(Filtration filter)
        {
            // Assign filterCriteria to orignal filter
            Filtration filterCriteria = filter;

            // If filter contains paging
            if (filter != null && filter.PageCriteria != null)
            {
                // create new filter criteria without paging criteria
                filterCriteria = new Filtration
                {
                    SearchCriteria = filter.SearchCriteria,
                };
            }

            // Count entity that match filtertion
            return(_context.Set <TEntity>().AppendFilterCriteria <TEntity, TId>(filterCriteria).Count());
        }
        public bool Any(Expression <Func <TEntity, bool> > query, Filtration filter)
        {
            // Assign filterCriteria to orignal filter
            Filtration filterCriteria = filter;

            // If filter contains paging
            if (filter != null && filter.PageCriteria != null)
            {
                // create new filter criteria without paging criteria
                filterCriteria = new Filtration
                {
                    SearchCriteria = filter.SearchCriteria,
                };
            }

            //// check existance of any of entities that match filtertion and query expression
            return(_context.Set <TEntity>().AppendFilterCriteria <TEntity, TId>(filterCriteria).Any(query));
        }
        // GET: TechnicalEquipments
        public ActionResult Index(string name)
        {
            IQueryable <TechnicalEquipment> tech = db.TechnicalEquipment.Include(p => p.NameTech);

            if (!String.IsNullOrEmpty(name) && !name.Equals("Все"))
            {
                tech = tech.Where(p => p.NameTech == name);
            }

            List <string> teams = db.TechnicalEquipment.Select(n => n.NameTech).ToList();
            // устанавливаем начальный элемент, который позволит выбрать всех
            /* teams.Insert(0, new Team { Name = "Все", Id = 0 });*/

            Filtration filter = new Filtration
            {
                Tech  = tech.ToList(),
                Names = new SelectList(teams)
            };

            return(View(filter));
        }
예제 #13
0
        public DescriptiveResponse <FilteredCollection <TRead> > FilterCollection(Filtration filter)
        {
            try
            {
                // Add userId in case of entity of type managed entity
                if (typeof(TRead).IsSubclassOf(typeof(ManagedEntity <TId, TUId>)))
                {
                    if (filter == null)
                    {
                        filter = new Filtration();
                    }

                    if (filter.SearchCriteria == null)
                    {
                        filter.SearchCriteria = new List <FilterSearchCriteria>();
                    }

                    filter.SearchCriteria.Add(new FilterSearchCriteria
                    {
                        Field     = "CreatedBy",
                        Operator  = LogicalOperator.Equal,
                        SearchKey = UserUtility <TUId> .CurrentUser.UserId.ToString()
                    });
                }

                // Find all items that match filteration
                FilteredCollection <TRead> filteredCollection = _readRepository.Find(filter);

                // Return success response
                return(DescriptiveResponse <FilteredCollection <TRead> > .Success(filteredCollection));
            }
            catch (Exception ex)
            {
                // Log error
                Logger.Log(ex);

                // return unexpected error
                return(DescriptiveResponse <FilteredCollection <TRead> > .Error(ErrorStatus.UNEXPECTED_ERROR));
            }
        }
        /// <summary>
        /// Append filter criteria to strong typed querable
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <typeparam name="TId"></typeparam>
        /// <param name="query"></param>
        /// <param name="filter"></param>
        /// <returns></returns>
        public static IQueryable <TEntity> AppendFilterCriteria <TEntity, TId>(this IQueryable <TEntity> query, Filtration filter) where TEntity : IEntity <TId>
        {
            // No search criteria
            if (filter == null)
            {
                // Return the orignal query
                return(query);
            }

            // Append search criteria
            query = AppendFilterSearchCriteria <TEntity, TId>(query, filter.SearchCriteria);

            // Append sort criteria
            query = AppendFilterSortCriteria <TEntity, TId>(query, filter.SortCriteria);

            // Append paging criteria
            query = AppendFilterPagingCriteria <TEntity, TId>(query, filter.PageCriteria);

            // Return result query
            return(query);
        }
 public TEntity GetSingleOrDefault(Expression <Func <TEntity, bool> > query, Filtration filter)
 {
     // Get FirstOrDefault that match the filtertion and query expression
     return(_context.Set <TEntity>().AppendFilterCriteria <TEntity, TId>(filter).FirstOrDefault(query));
 }
 public virtual DescriptiveResponse <FilteredCollection <TRead> > Filter(Filtration filter)
 {
     return(Manager.FilterCollection(filter));
 }
 public DescriptiveResponse <UserDTO> GetUser(Filtration filter)
 {
     return(_userManager.FilterUsers(filter));
 }
 public TEntity GetSingleOrDefault(Filtration filter)
 {
     // Get FirstOrDefault that match the filtertion
     return(_context.Set <TEntity>().AppendFilterCriteria <TEntity, TId>(filter).FirstOrDefault());
 }
        public FilteredCollection <TEntity> Find(Expression <Func <TEntity, bool> > query, Filtration filter)
        {
            IEnumerable <TEntity> collection = _context.Set <TEntity>().Where(query).AppendFilterCriteria <TEntity, TId>(filter).AsEnumerable();

            return(new FilteredCollection <TEntity>
            {
                Collection = collection,
                TotalCount = Count(query, filter)
            });
        }