Exemplo n.º 1
0
        public static List <BaseNpc> Find(FilterRule Rule, FilterArgs Args)
        {
            var List = FilterTeam.Find(Rule.TeamType, Args);

            List = FilterRange.Find(List, Rule.RangeType, Args);
            return(FilterNpc.Find(List, Rule.NpcType, Args));
        }
Exemplo n.º 2
0
        public virtual JsonResult Read(DataSourceRequest request, FilterRange range)
        {
            if (range.Start == DateTime.MinValue && range.End == DateTime.MinValue)
            {
                DateTime date = DateTime.Now;
                range.Start = FirstDayOfWeek(DateTime.Now);
                range.End   = LastDayOfWeek(DateTime.Now);
            }

            string FilterTask = SessionControl.SessionManager.GetScriptParameterByKey("FilterTask", HttpContext.Session);
            string clientId   = SessionControl.SessionManager.GetClientId(HttpContext.Session);
            string userId     = SessionControl.SessionManager.GetUserId(HttpContext.Session);
            IQueryable <ContactTaskViewModel> lstTask = null;

            switch (FilterTask)
            {
            case "CLIENT":
                lstTask = taskService.GetAll(clientId);
                break;

            case "USER":
                lstTask = taskService.GetAll(clientId, userId);
                break;
            }

            return(Json(lstTask.ToDataSourceResult(request)));
        }
Exemplo n.º 3
0
 private static object GetSingleValueFromRange(FilterRange filterRange)
 {
     return(filterRange
            .Start.IsNull()
         ? filterRange.End
         : filterRange.Start);
 }
Exemplo n.º 4
0
        public IQueryable <Post> GetPostsWithinRange(FilterRange filter)
        {
            bool isAdmin = IsAdmin();

            return(_cache
                   .Where(p => p.PubDate >= filter.Start && p.PubDate <= filter.End && (p.IsPublished || isAdmin)).AsQueryable());
        }
Exemplo n.º 5
0
        public void FilterRange_IsValid_Reports_Correct_Value()
        {
            foreach (FilterCondition condition in Enum.GetValues(typeof(FilterCondition)))
            {
                foreach (var reverseCondition in new bool[] { false, true })
                {
                    foreach (var lowerValue in new int?[] { null, 0, 1, 2 })
                    {
                        foreach (var upperValue in new int?[] { null, 0, 1, 2 })
                        {
                            var filter = new FilterRange <int>()
                            {
                                Condition        = condition,
                                ReverseCondition = reverseCondition,
                                LowerValue       = lowerValue,
                                UpperValue       = upperValue,
                            };

                            var result = filter.IsValid;

                            var expectedResult = condition == FilterCondition.Between && (lowerValue != null || upperValue != null);
                            Assert.AreEqual(expectedResult, result, "{0}/{1}/{2}/{3}", condition, reverseCondition, lowerValue, upperValue);
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Constructor that initializes all QueryFilter properties.
 /// </summary>
 public sysdiagramsFilter()
 {
     name = new FilterString();
     principalid = new FilterRange<int>();
     diagramid = new FilterRange<int>();
     version = new FilterRange<int>();
 }
Exemplo n.º 7
0
        public void FilterRange_NormaliseRange_Swaps_Upper_And_Lower_When_Appropriate()
        {
            foreach (var lowerValue in new int?[] { null, 0, 1, 2 })
            {
                foreach (var upperValue in new int?[] { null, 0, 1, 2 })
                {
                    var filter = new FilterRange <int>()
                    {
                        LowerValue = lowerValue,
                        UpperValue = upperValue,
                    };

                    filter.NormaliseRange();

                    var expectedLower = lowerValue;
                    var expectedUpper = upperValue;
                    if (expectedLower != null && expectedUpper != null && expectedLower > expectedUpper)
                    {
                        expectedLower = upperValue;
                        expectedUpper = lowerValue;
                    }

                    Assert.AreEqual(expectedLower, filter.LowerValue, "{0}/{1}", lowerValue, upperValue);
                    Assert.AreEqual(expectedUpper, filter.UpperValue, "{0}/{1}", lowerValue, upperValue);
                }
            }
        }
Exemplo n.º 8
0
 public LcmsFeatureFilteringOptions()
 {
     FilterOnMinutes           = false;
     FeatureLengthRangeScans   = new FilterRange(MIN_FEATURE_LENGTH, MAX_FEATURE_LENGTH);
     FeatureLengthRangeMinutes = new FilterRange(double.MinValue, double.MaxValue);
     MinimumDataPoints         = 3;
 }
 /// <summary>
 /// Constructor that initializes all QueryFilter properties.
 /// </summary>
 public OrderDetailsFilter()
 {
     OrderID = new FilterRange<int>();
     ProductID = new FilterRange<int>();
     UnitPrice = new FilterRange<decimal>();
     Quantity = new FilterRange<short>();
     Discount = new FilterRange<Single>();
 }
Exemplo n.º 10
0
 public FilterRangesModel()
 {
     Height      = new FilterRange();
     Width       = new FilterRange();
     Length      = new FilterRange();
     SleepLength = new FilterRange();
     SleepWidth  = new FilterRange();
     Price       = new FilterRange();
 }
Exemplo n.º 11
0
        public MsFeatureFilteringOptions()
        {
            MzRange                 = new FilterRange();
            MinimumIntensity        = 0;
            MinimumDeisotopingScore = MINIMUM_DEISOTOPING_SCORE;
            ChargeRange             = new FilterRange(1, 6);

            ShouldUseIntensityFilter   = false;
            ShouldUseMzFilter          = false;
            ShouldUseDeisotopingFilter = true;
            ShouldUseChargeFilter      = true;
        }
Exemplo n.º 12
0
        /// <summary>
        ///     Filters the clusters based on the given mass and NET range
        /// </summary>
        public void Filter(FilterRange monoisotopicMass, FilterRange net)
        {
            m_filterViewModel.MassRange.Minimum = monoisotopicMass.Minimum;
            m_filterViewModel.MassRange.Maximum = monoisotopicMass.Maximum;
            m_filterViewModel.NetRange.Minimum  = net.Minimum;
            m_filterViewModel.NetRange.Maximum  = net.Maximum;

            m_filterViewModel.MassRange.ShouldUse = true;
            m_filterViewModel.NetRange.ShouldUse  = true;

            Filter();
        }
        public void ValidateCorrectly(bool expectedValid, object start, object end, RangeOperator op)
        {
            var sut = new FilterRange
            {
                Start         = start,
                End           = end,
                RangeOperator = op
            };

            Assert.Equal(expectedValid, sut.IsValid);
            Assert.Equal(!expectedValid, sut.IsInvalid);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Adds a single criteria to the statement passed across
        /// </summary>
        /// <param name="criteriaText"></param>
        /// <param name="filter"></param>
        /// <param name="parameters"></param>
        /// <param name="fieldName"></param>
        /// <param name="startDateParameterName"></param>
        /// <param name="endDateParameterName"></param>
        public static void AddCriteria(StringBuilder criteriaText, FilterRange <DateTime> filter, DynamicParameters parameters, string fieldName, string startDateParameterName, string endDateParameterName)
        {
            HandleDateRangeFilter(filter,
                                  (bothUsed) => { AddWhereClause(criteriaText, fieldName, String.Format(" {0} @{1}", !filter.ReverseCondition ? ">=" : "<", startDateParameterName), openParenthesis: bothUsed); },
                                  (bothUsed) => { AddWhereClause(criteriaText, fieldName, String.Format(" {0} @{1}", !filter.ReverseCondition ? "<=" : ">", endDateParameterName), useOR: bothUsed && filter.ReverseCondition, closeParenthesis: bothUsed); }
                                  );

            HandleDateRangeFilter(filter,
                                  (bothUsed) => { parameters.Add(startDateParameterName, filter.LowerValue); },
                                  (bothUsed) => { parameters.Add(endDateParameterName, filter.UpperValue); }
                                  );
        }
 /// <summary>
 /// Constructor that initializes all QueryFilter properties.
 /// </summary>
 public ProductsFilter()
 {
     ProductID = new FilterRange<int>();
     ProductName = new FilterString();
     SupplierID = new FilterRange<int>();
     CategoryID = new FilterRange<int>();
     QuantityPerUnit = new FilterString();
     UnitPrice = new FilterRange<decimal>();
     UnitsInStock = new FilterRange<short>();
     UnitsOnOrder = new FilterRange<short>();
     ReorderLevel = new FilterRange<short>();
     Discontinued = new FilterEquatable<bool?>();
 }
 /// <summary>
 /// Constructor that initializes all QueryFilter properties.
 /// </summary>
 public SuppliersFilter()
 {
     SupplierID = new FilterRange<int>();
     CompanyName = new FilterString();
     ContactName = new FilterString();
     ContactTitle = new FilterString();
     Address = new FilterString();
     City = new FilterString();
     Region = new FilterString();
     PostalCode = new FilterString();
     Country = new FilterString();
     Phone = new FilterString();
     Fax = new FilterString();
     HomePage = new FilterString();
 }
Exemplo n.º 17
0
        private void FilterFromView()
        {
            if (m_clustersPlotModel == null)
            {
                return;
            }


            var model = m_clustersPlotModel.Model;
            //var viewport = m_clusterChart.ViewPort;
            var mass = new FilterRange(model.DefaultYAxis.ActualMinimum, model.DefaultYAxis.ActualMaximum);
            var net  = new FilterRange(model.DefaultXAxis.ActualMinimum, model.DefaultXAxis.ActualMaximum);

            m_clusterTreeModel.Filter(mass, net);
        }
Exemplo n.º 18
0
        public static Filter SetRange(this Filter filter, object start = null, object end = null, RangeOperator rangeOperator = (RangeOperator)0)
        {
            filter ??= new Filter();

            var range = new FilterRange
            {
                Start         = start,
                End           = end,
                RangeOperator = rangeOperator,
            };

            filter.Range = range;

            return(filter);
        }
Exemplo n.º 19
0
        public void FilterRange_Constructor_Initialises_To_Known_State_And_Properties_Work()
        {
            var filter = new FilterRange <int>();

            TestUtilities.TestProperty(filter, r => r.Condition, FilterCondition.Invalid, FilterCondition.Equals);
            TestUtilities.TestProperty(filter, r => r.ReverseCondition, false);
            TestUtilities.TestProperty(filter, r => r.LowerValue, null, 1);
            TestUtilities.TestProperty(filter, r => r.UpperValue, null, 2);

            filter = new FilterRange <int>(7, 900);
            TestUtilities.TestProperty(filter, r => r.Condition, FilterCondition.Between, FilterCondition.Equals);
            TestUtilities.TestProperty(filter, r => r.ReverseCondition, false);
            TestUtilities.TestProperty(filter, r => r.LowerValue, 7, 1);
            TestUtilities.TestProperty(filter, r => r.UpperValue, 900, 2);
        }
Exemplo n.º 20
0
 /// <summary>
 /// Constructor that initializes all QueryFilter properties.
 /// </summary>
 public OrdersFilter()
 {
     OrderID = new FilterRange<int>();
     CustomerID = new FilterString();
     EmployeeID = new FilterRange<int>();
     OrderDate = new FilterRange<DateTime>();
     RequiredDate = new FilterRange<DateTime>();
     ShippedDate = new FilterRange<DateTime>();
     ShipVia = new FilterRange<int>();
     Freight = new FilterRange<decimal>();
     ShipName = new FilterString();
     ShipAddress = new FilterString();
     ShipCity = new FilterString();
     ShipRegion = new FilterString();
     ShipPostalCode = new FilterString();
     ShipCountry = new FilterString();
 }
Exemplo n.º 21
0
        /// <summary>
        /// Decodes a double range filter's upper or lower value and condition.
        /// </summary>
        /// <param name="filterRange"></param>
        /// <param name="name"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        protected FilterRange <double> DecodeDoubleRangeFilter(FilterRange <double> filterRange, string name, string value)
        {
            if (filterRange == null)
            {
                filterRange = new FilterRange <double>();
            }
            var conditionChar = DecodeFilter(filterRange, name);

            switch (conditionChar)
            {
            case 'L':   filterRange.LowerValue = QueryNDouble(value); break;

            case 'U':   filterRange.UpperValue = QueryNDouble(value); break;

            default:    filterRange.Condition = FilterCondition.Invalid; break;
            }

            return(filterRange);
        }
Exemplo n.º 22
0
        private FilterRange <DateTime> DecodeDateRangeFilter(FilterRange <DateTime> filterRange, string name, string value)
        {
            if (filterRange == null)
            {
                filterRange = new FilterRange <DateTime>();
            }
            var conditionChar = DecodeFilter(filterRange, name);

            switch (conditionChar)
            {
            case 'L':   filterRange.LowerValue = QueryNDateTime(value); break;

            case 'U':   filterRange.UpperValue = QueryNDateTime(value); break;

            default:    filterRange.Condition = FilterCondition.Missing; break;
            }

            return(filterRange);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Decodes an int range filter's upper or lower value and condition.
        /// </summary>
        /// <param name="filterRange"></param>
        /// <param name="name"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        protected FilterRange <int> DecodeIntRangeFilter(FilterRange <int> filterRange, string name, string value)
        {
            if (filterRange == null)
            {
                filterRange = new FilterRange <int>();
            }
            var conditionChar = DecodeFilter(filterRange, name);

            switch (conditionChar)
            {
            case 'L':   filterRange.LowerValue = QueryNInt(value); break;

            case 'U':   filterRange.UpperValue = QueryNInt(value); break;

            default:    filterRange.Condition = FilterCondition.Missing; break;
            }

            return(filterRange);
        }
 /// <summary>
 /// Constructor that initializes all QueryFilter properties.
 /// </summary>
 public EmployeesFilter()
 {
     EmployeeID = new FilterRange<int>();
     LastName = new FilterString();
     FirstName = new FilterString();
     Title = new FilterString();
     TitleOfCourtesy = new FilterString();
     BirthDate = new FilterRange<DateTime>();
     HireDate = new FilterRange<DateTime>();
     Address = new FilterString();
     City = new FilterString();
     Region = new FilterString();
     PostalCode = new FilterString();
     Country = new FilterString();
     HomePhone = new FilterString();
     Extension = new FilterString();
     Notes = new FilterString();
     ReportsTo = new FilterRange<int>();
     PhotoPath = new FilterString();
 }
Exemplo n.º 25
0
        public void FilterRange_Passes_Returns_Correct_Results()
        {
            foreach (FilterCondition condition in Enum.GetValues(typeof(FilterCondition)))
            {
                foreach (var reverseCondition in new bool[] { false, true })
                {
                    foreach (var lowerValue in new int?[] { null, 0, 1, 2 })
                    {
                        foreach (var upperValue in new int?[] { null, 0, 1, 2 })
                        {
                            foreach (var value in new int?[] { null, -1, 0, 1, 2, 3 })
                            {
                                var filter = new FilterRange <int>()
                                {
                                    Condition        = condition,
                                    ReverseCondition = reverseCondition,
                                    LowerValue       = lowerValue,
                                    UpperValue       = upperValue,
                                };

                                var result = filter.Passes(value);

                                var expectedResult = true;
                                if (filter.IsValid)
                                {
                                    expectedResult = value == null ? false : (lowerValue == null || value >= lowerValue) && (upperValue == null || value <= upperValue);
                                    if (reverseCondition)
                                    {
                                        expectedResult = !expectedResult;
                                    }
                                }

                                Assert.AreEqual(expectedResult, result, "{0}/{1}/{2}/{3}/{4}", condition, reverseCondition, value, lowerValue, upperValue);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 26
0
        public static void HandleDateRangeFilter(FilterRange <DateTime> filter, Action <bool> onLowerValue, Action <bool> onUpperValue)
        {
            if (filter != null)
            {
                switch (filter.Condition)
                {
                case FilterCondition.Between:
                    var lowerPresent = filter.LowerValue != null && filter.LowerValue.Value.Year != DateTime.MinValue.Year;
                    var upperPresent = filter.UpperValue != null && filter.UpperValue.Value.Year != DateTime.MaxValue.Year;
                    if (lowerPresent)
                    {
                        onLowerValue(lowerPresent && upperPresent);
                    }
                    if (upperPresent)
                    {
                        onUpperValue(lowerPresent && upperPresent);
                    }
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
        }
Exemplo n.º 27
0
 /// <summary>
 /// Constructor that initializes all QueryFilter properties.
 /// </summary>
 public RegionFilter()
 {
     RegionID = new FilterRange<int>();
     RegionDescription = new FilterString();
 }
Exemplo n.º 28
0
 public LcmsFeatureFilteringOptions()
 {
     FeatureLengthRange = new FilterRange(MIN_FEATURE_LENGTH, MAX_FEATURE_LENGTH);
     TreatAsTimeNotScan = false;
 }
 /// <summary>
 /// Constructor that initializes all QueryFilter properties.
 /// </summary>
 public ShippersFilter()
 {
     ShipperID = new FilterRange<int>();
     CompanyName = new FilterString();
     Phone = new FilterString();
 }
 /// <summary>
 /// Constructor that initializes all QueryFilter properties.
 /// </summary>
 public CategoriesFilter()
 {
     CategoryID = new FilterRange<int>();
     CategoryName = new FilterString();
     Description = new FilterString();
 }
 /// <summary>
 /// Constructor that initializes all QueryFilter properties.
 /// </summary>
 public TerritoriesFilter()
 {
     TerritoryID = new FilterString();
     TerritoryDescription = new FilterString();
     RegionID = new FilterRange<int>();
 }
Exemplo n.º 32
0
        private void FilterFromView()
        {
            if (m_clustersPlotModel == null)
                return;

            var model = m_clustersPlotModel.Model;
            //var viewport = m_clusterChart.ViewPort;
            var mass = new FilterRange(model.DefaultYAxis.ActualMinimum, model.DefaultYAxis.ActualMaximum);
            var net = new FilterRange(model.DefaultXAxis.ActualMinimum, model.DefaultXAxis.ActualMaximum);
            m_clusterTreeModel.Filter(mass, net);
        }
        /// <summary>
        ///     Filters the clusters based on the given mass and NET range
        /// </summary>
        public void Filter(FilterRange monoisotopicMass, FilterRange net)
        {
            m_filterViewModel.MassRange.Minimum = monoisotopicMass.Minimum;
            m_filterViewModel.MassRange.Maximum = monoisotopicMass.Maximum;
            m_filterViewModel.NetRange.Minimum = net.Minimum;
            m_filterViewModel.NetRange.Maximum = net.Maximum;

            m_filterViewModel.MassRange.ShouldUse = true;
            m_filterViewModel.NetRange.ShouldUse = true;

            Filter();
        }
Exemplo n.º 34
0
        public static Query AddFilter(this Query query, string property = null, object[] values = null, FilterRange range = null, bool?includeNulls = null)
        {
            var filter = new Filter
            {
                Property     = property,
                includeNulls = includeNulls,
                Range        = range,
                Values       = values
            };

            if (query.Filters == null)
            {
                query.Filters = new[] { filter };
            }
            else
            {
                var filters = new List <Filter>(query.Filters)
                {
                    filter
                };

                query.Filters = filters.ToArray();
            }

            return(query);
        }
        public virtual JsonResult Read([DataSourceRequest] DataSourceRequest request, FilterRange range)
        {
            //var t = taskService.GetAll();
            var data = taskService.GetRange(range.Start, range.End);

            return(Json(data.ToDataSourceResult(request)));
            //return Json(taskService.GetAll().ToDataSourceResult(request));
        }
 /// <summary>
 /// Constructor that initializes all QueryFilter properties.
 /// </summary>
 public EmployeeTerritoriesFilter()
 {
     EmployeeID = new FilterRange<int>();
     TerritoryID = new FilterString();
 }