Ejemplo n.º 1
0
        private void InitialSetFilterDescriptor(FilterDescriptor value)
        {
            CompositeFilterDescriptor filterDescriptor1 = value as CompositeFilterDescriptor;

            if (filterDescriptor1 == null)
            {
                filterDescriptor1 = new CompositeFilterDescriptor();
                filterDescriptor1.FilterDescriptors.Add(value);
            }
            if (filterDescriptor1.FilterDescriptors.Count == 0)
            {
                filterDescriptor1.FilterDescriptors.Add(new FilterDescriptor(this.column.Name, FilterOperator.None, (object)null));
            }
            this.compositeFilterDescriptor = filterDescriptor1;
            DataFilterRootNode node = this.radDataFilter1.Nodes[0] as DataFilterRootNode;

            this.radDataFilter1.DataFilterElement.ClearChildNodes((DataFilterGroupNode)node);
            node.LogicalOperator = filterDescriptor1.LogicalOperator;
            foreach (FilterDescriptor filterDescriptor2 in (Collection <FilterDescriptor>)filterDescriptor1.FilterDescriptors)
            {
                node.Filters.Add(filterDescriptor2);
            }
            foreach (FilterDescriptor filter in (Collection <FilterDescriptor>)node.Filters)
            {
                this.radDataFilter1.DataFilterElement.AddChildNodes(filter, (RadTreeNode)node, false);
            }
        }
Ejemplo n.º 2
0
        private FilterDescriptor GetFilterDescriptor(CompositeFilterDescriptor composite)
        {
            CompositeFilterDescriptor filterDescriptor = new CompositeFilterDescriptor();
            DataFilterGroupNode       node1            = this.radDataFilter1.DataFilterElement.Nodes[0] as DataFilterGroupNode;

            filterDescriptor.LogicalOperator = node1.LogicalOperator;
            foreach (RadTreeNode node2 in (Collection <RadTreeNode>)node1.Nodes)
            {
                DataFilterGroupNode dataFilterGroupNode = node2 as DataFilterGroupNode;
                if (dataFilterGroupNode != null && dataFilterGroupNode.CompositeDescriptor.FilterDescriptors.Count > 0)
                {
                    filterDescriptor.FilterDescriptors.Add((FilterDescriptor)dataFilterGroupNode.CompositeDescriptor);
                }
                DataFilterCriteriaNode filterCriteriaNode = node2 as DataFilterCriteriaNode;
                if (filterCriteriaNode != null && filterCriteriaNode.FilterOperator != FilterOperator.None)
                {
                    filterDescriptor.FilterDescriptors.Add(filterCriteriaNode.Descriptor);
                }
            }
            if (filterDescriptor.FilterDescriptors.Count == 0)
            {
                filterDescriptor = (CompositeFilterDescriptor)null;
            }
            else if (filterDescriptor.FilterDescriptors.Count == 1)
            {
                return(filterDescriptor.FilterDescriptors[0]);
            }
            return((FilterDescriptor)filterDescriptor);
        }
Ejemplo n.º 3
0
        private static void MappViewFields(IFilterDescriptor f, string current, string toMap)
        {
            var type = f.GetType();

            if (type.Name != "FilterDescriptor")
            {
                CompositeFilterDescriptor cfd = (CompositeFilterDescriptor)f;

                foreach (var item in cfd.FilterDescriptors)
                {
                    MappViewFields(item, current, toMap);
                }
            }
            else
            {
                FilterDescriptor fd = (FilterDescriptor)f;
                if (fd.Member == current)
                {
                    fd.Member = toMap;
                }
                if (fd.Member.ToLower().Contains("date"))
                {
                    fd.Value = ((DateTime)fd.Value).ToUniversalTime();
                }
            }
        }
Ejemplo n.º 4
0
        private void InitialSetFilterDescriptor(FilterDescriptor value)
        {
            CompositeFilterDescriptor filterDescriptor = value as CompositeFilterDescriptor;

            if (filterDescriptor == null)
            {
                this.compositeFilterDescriptor = new CompositeFilterDescriptor();
                this.compositeFilterDescriptor.FilterDescriptors.Add(value);
            }
            else
            {
                this.compositeFilterDescriptor = filterDescriptor;
            }
            while (this.compositeFilterDescriptor.FilterDescriptors.Count < 2)
            {
                if ((object)this.DataType == (object)typeof(DateTime))
                {
                    this.compositeFilterDescriptor.FilterDescriptors.Add((FilterDescriptor) new DateFilterDescriptor(this.column.Name, FilterOperator.None, new DateTime?()));
                }
                else
                {
                    this.compositeFilterDescriptor.FilterDescriptors.Add(new FilterDescriptor(this.column.Name, FilterOperator.None, (object)null));
                }
            }
        }
Ejemplo n.º 5
0
        private void FillEmployeeCombo()
        {
            Operation.BeginOperation(this);

            this.Invoke((MethodInvoker)delegate
            {
                this.EmployeeComboBox.MultiColumnComboBoxElement.DropDownWidth = 500;

                this.EmployeeComboBox.AutoFilter = true;
                this.EmployeeComboBox.ValueMember = "ID";
                this.EmployeeComboBox.DisplayMember = "EmployeeName";
            });
            var q = EmployeeCmd.GetAll();
            this.Invoke((MethodInvoker)delegate
            {
                EmployeeComboBox.DataSource = q;
                this.EmployeeComboBox.AutoFilter = true;
                CompositeFilterDescriptor compositeFilter = new CompositeFilterDescriptor();
                FilterDescriptor empname = new FilterDescriptor("EmployeeName", FilterOperator.Contains, "");
                FilterDescriptor empNumber = new FilterDescriptor("EmployeejobNumber", FilterOperator.Contains, "");
                compositeFilter.FilterDescriptors.Add(empname);
                compositeFilter.FilterDescriptors.Add(empNumber);
                compositeFilter.LogicalOperator = FilterLogicalOperator.Or;

                this.EmployeeComboBox.EditorControl.FilterDescriptors.Add(compositeFilter);

            });
            Operation.EndOperation(this);


            th.Abort();

            
        }
        protected override CompositeFilterDescriptor CreateFilter <TValue>(Expression <Func <TModel, TValue> > expression)
        {
            var composite = new CompositeFilterDescriptor
            {
                LogicalOperator = FilterCompositionLogicalOperator.And
            };

            var descriptor = new FilterDescriptor {
                Member = expression.MemberWithoutInstance()
            };

            var schedulerEventInterface = typeof(ISchedulerEvent);

            var currentMember = descriptor.Member;

            if (schedulerEventInterface.GetProperty(currentMember) != null)
            {
                var updatedMember = Char.ToLowerInvariant(currentMember[0]) + currentMember.Substring(1);
                descriptor.Member = updatedMember;
            }

            composite.FilterDescriptors.Add(descriptor);

            Filters.Add(composite);

            return(composite);
        }
 private CompositeFilterDescriptor GetCompositeFilterDescriptor(
     CompositeFilterDescriptor.DescriptorType desiredType,
     CompositeFilterDescriptor currentDescriptor,
     System.Type dataType)
 {
     return(currentDescriptor == null?CompositeFilterDescriptor.CreateDescriptor(desiredType, this.FieldName, dataType, (object[])null) : currentDescriptor.ConvertTo(desiredType, dataType));
 }
        protected virtual RadDropDownMenu CreateFilterMenu()
        {
            System.Type dataType = this.ViewInfo.GetColumnDataType(this.ColumnIndex);
            if ((object)dataType == null)
            {
                dataType = typeof(string);
            }
            CompositeFilterDescriptor descriptor = this.Descriptor as CompositeFilterDescriptor;
            int             descriptorType       = (int)CompositeFilterDescriptor.GetDescriptorType(descriptor);
            RadDropDownMenu radDropDownMenu      = new RadDropDownMenu();

            foreach (FilterOperationContext filterOperation in FilterOperationContext.GetFilterOperations(dataType))
            {
                RadFilterOperationMenuItem operationMenuItem = new RadFilterOperationMenuItem(filterOperation);
                operationMenuItem.IsChecked = descriptor == null && operationMenuItem.Operator == this.SelectedFilterOperator;
                operationMenuItem.Click    += new EventHandler(this.FilterMenuItem_Click);
                operationMenuItem.Text      = LocalizationProvider <RadVirtualGridLocalizationProvider> .CurrentProvider.GetLocalizedString(filterOperation.id);

                radDropDownMenu.Items.Add((RadItem)operationMenuItem);
            }
            radDropDownMenu.PopupOpening += new RadPopupOpeningEventHandler(this.contextMenu_PopupOpening);
            radDropDownMenu.PopupClosed  += new RadPopupClosedEventHandler(this.contextMenu_PopupClosed);
            this.InitializeMenuItemsText();
            return(radDropDownMenu);
        }
Ejemplo n.º 9
0
        protected virtual void OnButtonOkClick(EventArgs e)
        {
            CompositeFilterDescriptor filterDescriptor1 = new CompositeFilterDescriptor();

            filterDescriptor1.PropertyName    = this.DataColumn.Name;
            filterDescriptor1.LogicalOperator = FilterLogicalOperator.Or;
            if (this.calendarItem.IsChecked)
            {
                if (this.calendarItem.CalendarElement.Calendar.SelectedDates.Count == 0)
                {
                    DateFilterDescriptor filterDescriptor2 = new DateFilterDescriptor(this.DataColumn.Name, FilterOperator.IsEqualTo, new DateTime?(this.calendarItem.CalendarElement.Calendar.FocusedDate), false);
                    filterDescriptor1.FilterDescriptors.Add((FilterDescriptor)filterDescriptor2);
                }
                else
                {
                    foreach (DateTime selectedDate in this.calendarItem.CalendarElement.Calendar.SelectedDates)
                    {
                        DateFilterDescriptor filterDescriptor2 = new DateFilterDescriptor(this.DataColumn.Name, FilterOperator.IsEqualTo, new DateTime?(selectedDate), false);
                        filterDescriptor1.FilterDescriptors.Add((FilterDescriptor)filterDescriptor2);
                    }
                }
            }
            foreach (RadItem radItem in (RadItemCollection)this.Items)
            {
                FilterMenuCustomDateItem menuCustomDateItem = radItem as FilterMenuCustomDateItem;
                if (menuCustomDateItem != null && menuCustomDateItem.IsChecked && !this.SearchForAppliedFilterDescriptors((FilterDescriptor)filterDescriptor1, menuCustomDateItem.FilterDescriptor))
                {
                    filterDescriptor1.FilterDescriptors.Add(menuCustomDateItem.FilterDescriptor);
                }
            }
            this.FilterDescriptor = (FilterDescriptor)filterDescriptor1;
            this.OnFilterConfirmed();
        }
        private void calReportDate_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
        {
            RadGridView1.FilterDescriptors.Clear();

            DateTime firstOfMonth = new DateTime(calReportDate.SelectedDate.Value.Year, calReportDate.SelectedDate.Value.Month, 1);
            DateTime lastOfMonth = firstOfMonth.AddMonths(1).AddDays(-1);

            CompositeFilterDescriptor openDesc = new CompositeFilterDescriptor();
            openDesc.LogicalOperator = FilterCompositionLogicalOperator.And;
            openDesc.FilterDescriptors.Add(new FilterDescriptor("OpenedDate", FilterOperator.IsGreaterThan, firstOfMonth));
            openDesc.FilterDescriptors.Add(new FilterDescriptor("OpenedDate", FilterOperator.IsLessThan, lastOfMonth));

            CompositeFilterDescriptor closedDesc = new CompositeFilterDescriptor();
            closedDesc.LogicalOperator = FilterCompositionLogicalOperator.And;
            closedDesc.FilterDescriptors.Add(new FilterDescriptor("ClosedDate", FilterOperator.IsGreaterThan, firstOfMonth));
            closedDesc.FilterDescriptors.Add(new FilterDescriptor("ClosedDate", FilterOperator.IsLessThan, lastOfMonth));

            CompositeFilterDescriptor bothDesc = new CompositeFilterDescriptor();
            bothDesc.LogicalOperator = FilterCompositionLogicalOperator.Or;
            bothDesc.FilterDescriptors.Add(openDesc);
            bothDesc.FilterDescriptors.Add(closedDesc);

            RadGridView1.FilterDescriptors.Add(bothDesc);
            RadGridView1.Rebind();
        }
Ejemplo n.º 11
0
        public void TestMethod1()
        {
            var dsr = new DataSourceRequest();

            dsr.Aggregates = null;
            dsr.Filters    = null;
            dsr.Groups     = null;
            dsr.Page       = 1;
            dsr.PageSize   = 2;

            var sd = new SortDescriptor();

            sd.Member        = "url";
            sd.SortDirection = ListSortDirection.Ascending;
            sd.SortCompare   = null;
            dsr.Sorts        = new List <SortDescriptor>();
            dsr.Sorts.Add(sd);

            var fd = new CompositeFilterDescriptor();

            fd.LogicalOperator   = FilterCompositionLogicalOperator.And;
            fd.FilterDescriptors = new Kendo.Mvc.Infrastructure.Implementation.FilterDescriptorCollection();


            var fd2 = new CompositeFilterDescriptor();

            fd2.LogicalOperator   = FilterCompositionLogicalOperator.And;
            fd2.FilterDescriptors = new Kendo.Mvc.Infrastructure.Implementation.FilterDescriptorCollection();

            var fd21 = new FilterDescriptor();

            fd21.Member   = "blogId";
            fd21.Operator = FilterOperator.Contains;
            fd21.Value    = "1";
            fd2.FilterDescriptors.Add(fd21);

            var fd22 = new FilterDescriptor();

            fd22.Member   = "url";
            fd22.Operator = FilterOperator.Contains;
            fd22.Value    = "2";
            fd2.FilterDescriptors.Add(fd22);

            fd.FilterDescriptors.Add(fd2);

            var fd3 = new FilterDescriptor();

            fd3.Member   = "posts";
            fd3.Operator = FilterOperator.Contains;
            fd3.Value    = "3";
            fd.FilterDescriptors.Add(fd3);

            dsr.Filters = new List <IFilterDescriptor>();
            dsr.Filters.Add(fd);

            var query = new DSRQueryGenerator(dsr).GetQuery("Blogs");

            Console.WriteLine(query);
        }
        private void CreateFilters()
        {
            string dataMember = _column.DataMemberBinding.Path.Path;

            _compositeFilter = new CompositeFilterDescriptor();

            _filter = new FilterDescriptor(dataMember, FilterOperator.Contains, null);
            _compositeFilter.FilterDescriptors.Add(_filter);
        }
        public void CompositeFilter(CompositeFilterDescriptor root, ref IQueryable <Project> query)
        {
            var filters = FilterStateHelper.FlattenCompositeFilterDescriptor(root);

            foreach (var f in filters)
            {
                Filter(f, ref query);
            }
        }
Ejemplo n.º 14
0
        public void CompositeFilter(CompositeFilterDescriptor root, ref IQueryable <BusinessTier.Models.Task> query)
        {
            var filters = FilterStateHelper.FlattenCompositeFilterDescriptor(root);

            foreach (var f in filters)
            {
                Filter(f, ref query);
            }
        }
Ejemplo n.º 15
0
        public PipeFilterDescriptor(IEnumerable<GridViewDataColumn> columns)
        {
            this.compositeFilterDesriptor = new CompositeFilterDescriptor();
            this.compositeFilterDesriptor.LogicalOperator = FilterCompositionLogicalOperator.Or;

            foreach (GridViewDataColumn column in columns)
            {
                this.compositeFilterDesriptor.FilterDescriptors.Add(this.CreateFilterForColumn(column));
            }
        }
Ejemplo n.º 16
0
 public static DataSourceRequest NormalizeDateFilters(this DataSourceRequest request, DateTimePrecision precision)
 {
     // TODO: Add parameter validation.
     for (int i = 0; i < request.Filters.Count; ++i)
     {
         FilterDescriptor filter = request.Filters[i] as FilterDescriptor;
         if (filter != null && filter.ConvertedValue is DateTime && filter.Operator == FilterOperator.IsEqualTo)
         {
             DateTime val = (DateTime)filter.ConvertedValue;
             CompositeFilterDescriptor newFilter = new CompositeFilterDescriptor
             {
                 LogicalOperator = FilterCompositionLogicalOperator.And
             };
             DateTime lowerBound;
             DateTime upperBound;
             if (precision == DateTimePrecision.Seconds)
             {
                 lowerBound = val.TruncateToWholeSeconds();
                 upperBound = lowerBound.AddSeconds(1);
             }
             else if (precision == DateTimePrecision.Minutes)
             {
                 lowerBound = val.TruncateToWholeMinutes();
                 upperBound = lowerBound.AddMinutes(1);
             }
             else if (precision == DateTimePrecision.Hours)
             {
                 lowerBound = val.TruncateToWholeHours();
                 upperBound = lowerBound.AddHours(1);
             }
             else
             {
                 // If someone would be stupid enough to supply Hours | Minutes
                 throw new ArgumentException("Not supported precision. Only Second, Minute, Hour values are supported.", "precision");
             }
             newFilter.FilterDescriptors.Add(new FilterDescriptor
             {
                 Member     = filter.Member,
                 MemberType = filter.MemberType,
                 Operator   = FilterOperator.IsGreaterThanOrEqualTo,
                 Value      = lowerBound
             });
             newFilter.FilterDescriptors.Add(new FilterDescriptor
             {
                 Member     = filter.Member,
                 MemberType = filter.MemberType,
                 Operator   = FilterOperator.IsLessThan,
                 Value      = upperBound
             });
             request.Filters[i] = newFilter;
         }
     }
     return(request);
 }
Ejemplo n.º 17
0
        public void SearchFilterDescriptors_Test()
        {
            //arrange
            CompositeFilterDescriptor compositeFilter = null;

            //act
            var result = FilterStateHelper.SearchFilterDescriptors(compositeFilter, "priority");

            //assert
            Assert.NotNull(result);
        }
Ejemplo n.º 18
0
        protected virtual void CreateDateCustomItems()
        {
            this.AddCustomMenuItem(LocalizationProvider <RadGridLocalizationProvider> .CurrentProvider.GetLocalizedString("FilterFunctionToday"), (FilterDescriptor) new DateFilterDescriptor(this.DataColumn.Name, FilterOperator.IsEqualTo, new DateTime?(DateTime.Today), false));
            this.AddCustomMenuItem(LocalizationProvider <RadGridLocalizationProvider> .CurrentProvider.GetLocalizedString("FilterFunctionYesterday"), (FilterDescriptor) new DateFilterDescriptor(this.DataColumn.Name, FilterOperator.IsEqualTo, new DateTime?(DateTime.Today.AddDays(-1.0)), false));
            string localizedString = LocalizationProvider <RadGridLocalizationProvider> .CurrentProvider.GetLocalizedString("FilterFunctionDuringLast7days");

            CompositeFilterDescriptor filterDescriptor = new CompositeFilterDescriptor();

            filterDescriptor.FilterDescriptors.Add((FilterDescriptor) new DateFilterDescriptor(this.DataColumn.Name, FilterOperator.IsGreaterThanOrEqualTo, new DateTime?(DateTime.Today.AddDays(-7.0)), false));
            filterDescriptor.FilterDescriptors.Add((FilterDescriptor) new DateFilterDescriptor(this.DataColumn.Name, FilterOperator.IsLessThanOrEqualTo, new DateTime?(DateTime.Today), false));
            this.AddCustomMenuItem(localizedString, (FilterDescriptor)filterDescriptor);
        }
Ejemplo n.º 19
0
 public CustomFilterDescriptor(string filterValue, IEnumerable <string> filterPropertyNames)
 {
     compositeFilter = new CompositeFilterDescriptor();
     compositeFilter.LogicalOperator = FilterCompositionLogicalOperator.Or;
     foreach (string propertyName in filterPropertyNames)
     {
         this.compositeFilter.FilterDescriptors.Add(new FilterDescriptor(
                                                        propertyName,
                                                        FilterOperator.Contains,
                                                        filterValue));
     }
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Inicia a visita.
        /// </summary>
        /// <param name="logicalNode">Nó lógico.</param>
        public void StartVisit(ILogicalNode logicalNode)
        {
            var item = new CompositeFilterDescriptor {
                LogicalOperator = logicalNode.LogicalOperator
            };
            CompositeFilterDescriptor currentDescriptor = this.CurrentDescriptor as CompositeFilterDescriptor;

            if (currentDescriptor != null)
            {
                currentDescriptor.FilterDescriptors.Add(item);
            }
            this._context.Push(item);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Inicia a visita.
        /// </summary>
        /// <param name="operatorNode"></param>
        public void StartVisit(IOperatorNode operatorNode)
        {
            FilterDescriptor item = new FilterDescriptor {
                Operator = operatorNode.FilterOperator
            };
            CompositeFilterDescriptor currentDescriptor = this.CurrentDescriptor as CompositeFilterDescriptor;

            if (currentDescriptor != null)
            {
                currentDescriptor.FilterDescriptors.Add(item);
            }
            this._context.Push(item);
        }
		public CustomFilterDescriptor(IEnumerable<Telerik.Windows.Controls.GridViewColumn> columns)
		{
            this.compositeFilterDescriptor = new CompositeFilterDescriptor();
            this.compositeFilterDescriptor.LogicalOperator = FilterCompositionLogicalOperator.Or;

            foreach(GridViewColumn column in columns)
            {
                if(column is GridViewDataColumn)
                {
                    this.compositeFilterDescriptor.FilterDescriptors.Add(this.CreateFilterForColumn((GridViewDataColumn)column));
                }
            }
		}
Ejemplo n.º 23
0
        public CustomFilterDescriptor(IEnumerable <Telerik.Windows.Controls.GridViewColumn> columns)
        {
            this.compositeFilterDescriptor = new CompositeFilterDescriptor();
            this.compositeFilterDescriptor.LogicalOperator = FilterCompositionLogicalOperator.Or;

            foreach (GridViewColumn column in columns)
            {
                if (column is GridViewDataColumn)
                {
                    this.compositeFilterDescriptor.FilterDescriptors.Add(this.CreateFilterForColumn((GridViewDataColumn)column));
                }
            }
        }
Ejemplo n.º 24
0
        public void FlattenCompositeFilterDescriptor_ShouldThrowErrorIfUnsupportedOperatorUsed()
        {
            //arrange
            var compositeFilter = new CompositeFilterDescriptor()
            {
                Filters = new List <dynamic>()
            };

            //act
            compositeFilter.Logic = "OR";

            //assert
            Assert.Throws <NotImplementedException>(() => FilterStateHelper.FlattenCompositeFilterDescriptor(compositeFilter));
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Convert a FilterDescriptorCollection to FilterExpression
        /// </summary>
        /// <param name="filterDescriptors"></param>
        /// <returns></returns>
        public static FilterExpression Convert(FilterDescriptorCollection filterDescriptors)
        {
            FilterExpression        filter               = null;
            FilterExpression        tmpFilter            = null;
            List <FilterExpression> tmpFilterExpressions = new List <FilterExpression>();

            foreach (var f in filterDescriptors)
            {
                if (f.GetType() == typeof(CompositeFilterDescriptor))
                {
                    CompositeFilterDescriptor compositeFilterDescriptor = (CompositeFilterDescriptor)f;
                    FilterExpression          compositeFilter           = null;

                    compositeFilter = Convert(compositeFilterDescriptor.FilterDescriptors);

                    if (compositeFilter != null)
                    {
                        if (filter != null)
                        {
                            tmpFilter = filter;
                            filter    = BinaryFilterExpression.And(tmpFilter, compositeFilter);
                        }
                        else
                        {
                            filter = compositeFilter;
                        }
                    }
                }
                else
                if (f.GetType() == typeof(FilterDescriptor))
                {
                    FilterExpression fe = convert(f);
                    if (fe != null)
                    {
                        if (filter != null)
                        {
                            tmpFilter = filter;
                            filter    = BinaryFilterExpression.And(tmpFilter, fe);
                        }
                        else
                        {
                            filter = fe;
                        }
                    }
                }
            }

            return(filter);
        }
Ejemplo n.º 26
0
        public void StartVisit(ILogicalNode logicalNode)
        {
            CompositeFilterDescriptor filterDescriptor = new CompositeFilterDescriptor
            {
                LogicalOperator = logicalNode.LogicalOperator
            };

            CompositeFilterDescriptor compositeFilterDescriptor = CurrentDescriptor as CompositeFilterDescriptor;
            if (compositeFilterDescriptor != null)
            {
                compositeFilterDescriptor.FilterDescriptors.Add(filterDescriptor);
            }

            context.Push(filterDescriptor);
        }
Ejemplo n.º 27
0
        public void StartVisit(ILogicalNode logicalNode)
        {
            CompositeFilterDescriptor filterDescriptor = new CompositeFilterDescriptor
            {
                LogicalOperator = logicalNode.LogicalOperator
            };

            CompositeFilterDescriptor compositeFilterDescriptor = CurrentDescriptor as CompositeFilterDescriptor;

            if (compositeFilterDescriptor != null)
            {
                compositeFilterDescriptor.FilterDescriptors.Add(filterDescriptor);
            }

            context.Push(filterDescriptor);
        }
        private void CreateFilters()
        {
            string dataMember = this.column.DataMemberBinding.Path.Path;

            this.compositeFilter = new CompositeFilterDescriptor();

            this.fromFilter = new Telerik.Windows.Data.FilterDescriptor(dataMember
                                                                        , Telerik.Windows.Data.FilterOperator.IsGreaterThanOrEqualTo
                                                                        , null);
            this.compositeFilter.FilterDescriptors.Add(this.fromFilter);

            this.toFilter = new Telerik.Windows.Data.FilterDescriptor(dataMember
                                                                      , Telerik.Windows.Data.FilterOperator.IsLessThanOrEqualTo
                                                                      , null);
            this.compositeFilter.FilterDescriptors.Add(this.toFilter);
        }
Ejemplo n.º 29
0
        public void StartVisit(IOperatorNode operatorNode)
        {
            FilterDescriptor filterDescriptor = new FilterDescriptor
            {
                Operator = operatorNode.FilterOperator
            };

            CompositeFilterDescriptor compositeFilterDescriptor = CurrentDescriptor as CompositeFilterDescriptor;

            if (compositeFilterDescriptor != null)
            {
                compositeFilterDescriptor.FilterDescriptors.Add(filterDescriptor);
            }

            context.Push(filterDescriptor);
        }
        public void Should_return_composite_descriptor_for_and_node()
        {
            AndNode andNode = new AndNode()
            {
                First  = DateTimeComparison(),
                Second = StringFunction()
            };

            andNode.Accept(visitor);

            CompositeFilterDescriptor descriptor = (CompositeFilterDescriptor)visitor.Result;

            Assert.Equal(FilterCompositionLogicalOperator.And, descriptor.LogicalOperator);
            Assert.Equal(FilterOperator.IsEqualTo, ((FilterDescriptor)descriptor.FilterDescriptors[0]).Operator);
            Assert.Equal(FilterOperator.StartsWith, ((FilterDescriptor)descriptor.FilterDescriptors[1]).Operator);
        }
Ejemplo n.º 31
0
        public void FlattenCompositeFilterDescriptor_Test()
        {
            //arrange
            var compositeFilter = new CompositeFilterDescriptor()
            {
                Filters = new List <dynamic>()
                {
                    new { logic = "and" }
                }
            };

            //act
            compositeFilter.Logic = "and";

            //assert
            Assert.Throws <Newtonsoft.Json.JsonReaderException>(() => FilterStateHelper.FlattenCompositeFilterDescriptor(compositeFilter));
        }
Ejemplo n.º 32
0
        protected virtual CompositeFilterDescriptor GetCompositeFilterDescriptor(
            CompositeFilterDescriptor.DescriptorType desiredType,
            CompositeFilterDescriptor currentDescriptor)
        {
            CompositeFilterDescriptor filterDescriptor;

            if (currentDescriptor != null)
            {
                filterDescriptor             = currentDescriptor.Clone() as CompositeFilterDescriptor;
                filterDescriptor.NotOperator = desiredType == CompositeFilterDescriptor.DescriptorType.NotBetween;
            }
            else
            {
                filterDescriptor = CompositeFilterDescriptor.CreateDescriptor(desiredType, this.dataColumn.Name, this.dataColumn.DataType, (object[])null);
            }
            return(filterDescriptor);
        }
Ejemplo n.º 33
0
        private void fillcombo()
        {
            this.EmpComboBox.MultiColumnComboBoxElement.DropDownWidth = 500;
            this.EmpComboBox.ValueMember   = "Id";
            this.EmpComboBox.DisplayMember = "EmpName";
            EmpComboBox.DataSource         = EmpCmd.GetAll();
            this.EmpComboBox.AutoFilter    = true;
            CompositeFilterDescriptor compositeFilter = new CompositeFilterDescriptor();
            FilterDescriptor          empname         = new FilterDescriptor("EmpName", FilterOperator.Contains, "");
            FilterDescriptor          empNumber       = new FilterDescriptor("EmpNo", FilterOperator.Contains, "");

            compositeFilter.FilterDescriptors.Add(empname);
            compositeFilter.FilterDescriptors.Add(empNumber);
            compositeFilter.LogicalOperator = FilterLogicalOperator.Or;

            this.EmpComboBox.EditorControl.FilterDescriptors.Add(compositeFilter);
        }
Ejemplo n.º 34
0
        private List <IFilterDescriptor> GetFilterData(IQueryCollection args)
        {
            IEnumerable <IFilterDescriptor> filters = new List <IFilterDescriptor>();
            var filterKeys = args.Where(o => o.Key.Contains("filterModel"))
                             .GroupBy(o => o.Key.Substring(o.Key.IndexOf("[") + 1, o.Key.IndexOf("]") - o.Key.IndexOf("[") - 1))
                             .Select(o => o.Key).ToArray();

            foreach (var key in filterKeys)
            {
                string filterType = args.FirstOrDefault(o => o.Key.Contains($"filterModel[{key}][filterType]")).Value.ToString();
                string type       = args.FirstOrDefault(o => o.Key.Contains($"filterModel[{key}][type]")).Value.ToString();
                var    conditions = args.Where(o => o.Key.Contains($"filterModel[{key}][condition")).GroupBy(o => o.Key.Substring(o.Key.IndexOf("[condition"), 12)).ToArray();
                if (conditions.Any())
                {
                    string oprt            = args.First(o => o.Key.Contains($"filterModel[{key}][operator]")).Value.ToString();
                    var    compositeFilter = new CompositeFilterDescriptor();
                    IEnumerable <IFilterDescriptor> filterSubItems = new FilterDescriptorCollection();
                    var maxConditionCount = Math.Min(conditions.Count(), 9);
                    for (var i = 0; i < maxConditionCount; i++)
                    {
                        string condetionFilterType = args.FirstOrDefault(o => o.Key.Contains($"filterModel[{key}][condition{i + 1}][filterType]")).Value.ToString();
                        string conditionType       = args.FirstOrDefault(o => o.Key.Contains($"filterModel[{key}][condition{i + 1}][type]")).Value.ToString();
                        string conditionFilter     = args.FirstOrDefault(o => o.Key.Contains($"filterModel[{key}][condition{i + 1}][filter]")).Value.ToString();
                        string conditionFilterTo   = args.FirstOrDefault(o => o.Key.Contains($"filterModel[{key}][condition{i + 1}][filterTo]")).Value.ToString();

                        //toto should be correct
                        filterSubItems = AddFilterDescriptor(filterSubItems, key, condetionFilterType, conditionType, conditionFilter, conditionFilterTo);
                    }
                    var collection = new FilterDescriptorCollection();
                    collection.AddRange(filterSubItems.ToList());
                    compositeFilter.FilterDescriptors = collection;
                    compositeFilter.LogicalOperator   = (oprt == "AND" ? FilterCompositionLogicalOperator.And : FilterCompositionLogicalOperator.Or);
                    filters = filters.Concat(new List <IFilterDescriptor>()
                    {
                        compositeFilter
                    });
                }
                else
                {
                    string filter   = args.FirstOrDefault(o => o.Key.Contains($"filterModel[{key}][filter]")).Value.ToString();
                    string filterTo = args.FirstOrDefault(o => o.Key.Contains($"filterModel[{key}][filterTo]")).Value.ToString();
                    filters = AddFilterDescriptor(filters, key, filterType, type, filter, filterTo);
                }
            }
            return(filters.ToList());
        }
Ejemplo n.º 35
0
        protected virtual CompositeFilterDescriptor CreateFilter <TValue>(Expression <Func <TModel, TValue> > expression)
        {
            var composite = new CompositeFilterDescriptor
            {
                LogicalOperator = FilterCompositionLogicalOperator.And
            };

            var descriptor = new FilterDescriptor {
                Member = expression.MemberWithoutInstance()
            };

            composite.FilterDescriptors.Add(descriptor);

            Filters.Add(composite);

            return(composite);
        }
Ejemplo n.º 36
0
        private void FillCombo()
        {
            ///GetAllContractsProjectID
            ///

            Operation.BeginOperation(this);

            this.Invoke((MethodInvoker)delegate
            {
                this.EmployeeComboBox.MultiColumnComboBoxElement.DropDownWidth = 500;

                this.EmployeeComboBox.AutoFilter = true;
                this.EmployeeComboBox.ValueMember = "ID";
                this.EmployeeComboBox.DisplayMember = "Employee.EmployeeName";
            });
            var q = ContractCmd.GetAllContractsByproID(InformationsClass.ProjID);
            this.Invoke((MethodInvoker)delegate
            {
                EmployeeComboBox.DataSource = q;
                this.EmployeeComboBox.AutoFilter = true;
                CompositeFilterDescriptor compositeFilter = new CompositeFilterDescriptor();
                FilterDescriptor empname = new FilterDescriptor("Employee.EmployeeName", FilterOperator.Contains, "");
                FilterDescriptor empNumber = new FilterDescriptor("Employee.EmployeejobNumber", FilterOperator.Contains, "");
                compositeFilter.FilterDescriptors.Add(empname);
                compositeFilter.FilterDescriptors.Add(empNumber);
                compositeFilter.LogicalOperator = FilterLogicalOperator.Or;

                this.EmployeeComboBox.EditorControl.FilterDescriptors.Add(compositeFilter);
                //FillText
                XSalaryID = Tragetsalary.ID;
                EmployeeComboBox.Text = Tragetsalary.Contract.Employee.EmployeeName;
                SalaryTextBox.Text = Tragetsalary.Amount.ToString();
                FromonthDateTimePicker.Text = Tragetsalary.Formonth.ToString();
                ReleaseDateTimePicker.Text = Tragetsalary.IssueDate.ToString();
            });
            Operation.EndOperation(this);
          
            th.Abort();






        }
        public virtual void AddRange(IEnumerable<IFilterDescriptor> filters)
        {
            foreach (var filter in filters)
            {
                var composite = filter as CompositeFilterDescriptor;

                if (composite == null)
                {
                    composite = new CompositeFilterDescriptor
                    {
                        LogicalOperator = FilterCompositionLogicalOperator.And
                    };

                    composite.FilterDescriptors.Add(filter);
                }

                Filters.Add(composite);
            }
        }
Ejemplo n.º 38
0
        /// <summary>
        ///     初始化ViewModel
        ///     <remarks>
        ///         统一在此处创建并注册CollectionView集合。
        ///     </remarks>
        /// </summary>
        private void InitializeVM()
        {
            CtrlUnits = new QueryableDataServiceCollectionView<CtrlUnitDTO>(_context, _context.CtrlUnits);
            MaintainWorks = new QueryableDataServiceCollectionView<MaintainWorkDTO>(_context, _context.MaintainWorks);

            SnRegs = _service.CreateCollection(_context.SnRegs);
            var cfd = new CompositeFilterDescriptor {LogicalOperator = FilterCompositionLogicalOperator.Or};
            cfd.FilterDescriptors.Add(new FilterDescriptor("Status", FilterOperator.IsEqualTo, (int) SnStatus.在库));
            cfd.FilterDescriptors.Add(new FilterDescriptor("Status", FilterOperator.IsEqualTo, (int) SnStatus.在修));
            cfd.FilterDescriptors.Add(new FilterDescriptor("Status", FilterOperator.IsEqualTo, (int) SnStatus.出租));
            SnRegs.FilterDescriptors.Add(cfd);
            SnRegs.PageSize = 20;
            _service.RegisterCollectionView(SnRegs);

            SnHistories = _service.CreateCollection(_context.SnHistories);
            _service.RegisterCollectionView(SnHistories);
        }
Ejemplo n.º 39
0
        private void CreateFilters()
        {
            if (this.SelectedOperator.HasValue)
            {
                this._Column.DataControl.FilterDescriptors.SuspendNotifications();
                if (this._Filter == null)
                {
                    this._Filter = new CompositeFilterDescriptor();
                    this._Filter.LogicalOperator = FilterCompositionLogicalOperator.And;
                    ((CompositeFilterDescriptor)this._Column.DataControl.FilterDescriptors[1]).FilterDescriptors.Add(this._Filter);
                }
                this._Filter.FilterDescriptors.Clear();
                this._Filter.FilterDescriptors.Add(new FilterDescriptor(this._Column.FilterMemberPath,
                    this.SelectedOperator.Value, this.Value));

                this._Column.DataControl.FilterDescriptors.ResumeNotifications();
                //this._Column.ColumnFilterDescriptor.SuspendNotifications();
                //this._Column.ColumnFilterDescriptor.FieldFilter.Filter1.Operator = SelectedOperator.Value;
                //this._Column.ColumnFilterDescriptor.FieldFilter.Filter1.Value = Value;
                //this._Column.ColumnFilterDescriptor.ResumeNotifications();
            }
            this.IsActive = true; 
        }
Ejemplo n.º 40
0
        public void Prepare(Telerik.Windows.Controls.GridViewColumn columnToPrepare)
        {
            this._Column = columnToPrepare as GridViewBoundColumnBase;
            this.LocalValue = this.Value;
            this.LocalSelectedOperator = this.SelectedOperator;

            foreach (CompositeFilterDescriptor item in ((CompositeFilterDescriptor)this._Column.DataControl.FilterDescriptors[1]).FilterDescriptors)
            {
                if (item.FilterDescriptors.Count > 0)
                {
                    if (((FilterDescriptor)item.FilterDescriptors[0]).Member == this._Column.FilterMemberPath)
                    {
                        this._Filter = item;
                        break;
                    }
                }
            }
        }
Ejemplo n.º 41
0
        public void Prepare(Telerik.Windows.Controls.GridViewColumn columnToPrepare)
        {
            this._Column = columnToPrepare as GridViewBoundColumnBase;
            if (this.FromDateSelectedOperator.HasValue &&
                (this.FromDateSelectedOperator.Value == FilterOperator.IsGreaterThan || this.FromDateSelectedOperator.Value == FilterOperator.IsGreaterThanOrEqualTo))
            {
                this.ToDateVisibility = System.Windows.Visibility.Visible;
            }
            else
            {
                this.ToDateVisibility = System.Windows.Visibility.Collapsed;
            }
            this.LocalFromDateSelectedOperator = this.FromDateSelectedOperator;
            this.LocalFromDateValue = this.FromDateValue;
            this.LocalToDateSelectedOperator = this.ToDateSelectedOperator;
            this.LocalToDateValue = this.ToDateValue;

            foreach (CompositeFilterDescriptor item in ((CompositeFilterDescriptor)this._Column.DataControl.FilterDescriptors[1]).FilterDescriptors)
            {
                if (item.FilterDescriptors.Count > 0)
                {
                    if (((FilterDescriptor)item.FilterDescriptors[0]).Member == this._Column.FilterMemberPath)
                    {
                        this._Filter = item;
                        break;
                    }
                }
            }
        }
        /// <summary>
        /// Filters the pipes in the data grid
        /// </summary>
        private void ProcessSearchFilter()
        {
            //Apply the Filters
            View.TelerikGrid.FilterDescriptors.Clear(); //First remove all the old filters

            CompositeFilterDescriptor keyWordFilter = new CompositeFilterDescriptor { LogicalOperator = FilterCompositionLogicalOperator.Or };

            if (!string.IsNullOrEmpty(View.KeywordTextBox.Text))
            {
                keyWordFilter.FilterDescriptors.Add(new FilterDescriptor("Name", FilterOperator.Contains, SearchKeyword, false));
                keyWordFilter.FilterDescriptors.Add(new FilterDescriptor("Description", FilterOperator.Contains, SearchKeyword, false));
                View.TelerikGrid.FilterDescriptors.Add(keyWordFilter);
            }
        }
Ejemplo n.º 43
0
        private void CreateFilters()
        {
            this._Column.DataControl.FilterDescriptors.SuspendNotifications();
            if (this._Filter == null)
            {
                this._Filter = new CompositeFilterDescriptor();
                this._Filter.LogicalOperator = FilterCompositionLogicalOperator.And;
                ((CompositeFilterDescriptor)this._Column.DataControl.FilterDescriptors[1]).FilterDescriptors.Add(this._Filter);
            }
            this._Filter.FilterDescriptors.Clear();

            if (this.LocalFromDateSelectedOperator.HasValue && this.LocalFromDateValue.HasValue)
            {
                this.FromDateSelectedOperator = this.LocalFromDateSelectedOperator;
                this.FromDateValue = this.LocalFromDateValue;
                this.ToDateSelectedOperator = this.LocalToDateSelectedOperator;
                this.ToDateValue = this.LocalToDateValue;

                this._Filter.FilterDescriptors.Add(new FilterDescriptor(this._Column.FilterMemberPath,
                    this.FromDateSelectedOperator.Value, this.FromDateValue.Value));
      
                if (this.ToDateSelectedOperator.HasValue && this.ToDateValue.HasValue)
                {
                    this._Filter.FilterDescriptors.Add(new FilterDescriptor(this._Column.FilterMemberPath,
                        this.ToDateSelectedOperator.Value, this.ToDateValue.Value));
                }
            }
            this._Column.DataControl.FilterDescriptors.ResumeNotifications();

            this.IsActive = true;
            //if (LocalFromDateSelectedOperator.HasValue && LocalFromDateValue.HasValue)
            //{
            //    FromDateSelectedOperator = LocalFromDateSelectedOperator;
            //    FromDateValue = LocalFromDateValue;
            //    ToDateSelectedOperator = LocalToDateSelectedOperator;
            //    ToDateValue = LocalToDateValue;
            //    this._Column.ColumnFilterDescriptor.SuspendNotifications();
            //    this._Column.ColumnFilterDescriptor.FieldFilter.Filter1.Operator = FromDateSelectedOperator.Value;
            //    this._Column.ColumnFilterDescriptor.FieldFilter.Filter1.Value = FromDateValue.Value;
            //    if (ToDateSelectedOperator.HasValue && ToDateValue.HasValue)
            //    {
            //        this._Column.ColumnFilterDescriptor.FieldFilter.Filter2.Operator = ToDateSelectedOperator.Value;
            //        this._Column.ColumnFilterDescriptor.FieldFilter.Filter2.Value = ToDateValue.Value;
            //    }
            //    this._Column.ColumnFilterDescriptor.ResumeNotifications();
            //}
            //this.IsActive = true;
        }
Ejemplo n.º 44
0
 /// <summary>
 /// Composites the filter descriptor.
 /// </summary>
 /// <param name="descriptor">The descriptor.</param>
 /// <param name="result">The result.</param>
 /// <param name="radDataFilter">The RAD data filter.</param>
 private static void CompositeFilterDescriptor(Veyron.SharedTypes.IFilterDescriptor descriptor, ICompositeFilterDescriptor result, RadDataFilter radDataFilter)
 {
     foreach (var filter in descriptor.FilterDescriptors)
     {
         if (filter.FilterDescriptors == null || filter.FilterDescriptors.Count == 0)
             result.FilterDescriptors.Add(GetRadFilterDescriptor(filter, radDataFilter));
         else
         {
             var r = new CompositeFilterDescriptor
                         {
                             LogicalOperator = filter.LogicalOperator.ToRadLogicalOperator()
                         };
             CompositeFilterDescriptor(filter, r, radDataFilter);
             result.FilterDescriptors.Add(r);
         }
     }
 }
        /// <summary>
        /// The create filters.
        /// </summary>
        private void CreateFiltersForSelectFilter()
        {
            this.IsItemSelect = true;
            this._column.DataControl.FilterDescriptors.SuspendNotifications();
            if (this._filter1 == null)
            {
                this._filter1 = new CompositeFilterDescriptor();
                this._filter1.LogicalOperator = FilterCompositionLogicalOperator.Or;
                ((CompositeFilterDescriptor)this._column.DataControl.FilterDescriptors[1]).FilterDescriptors.Add(
                    this._filter1);
            }

            this._filter1.FilterDescriptors.Clear();

            List<FilteringDataItem> selectedItems =
                this.ItemsSource.Cast<FilteringDataItem>().Where(d => d.IsSelected).ToList();

            List<FilterDescriptor> filterDescriptors = new List<FilterDescriptor>();
            foreach (FilteringDataItem item in selectedItems)
            {
                if (item.IsSelected)
                {
                    if (this._column.DataMemberBinding.Path.Path == this._column.FilterMemberPath)
                    {
                        filterDescriptors.Add(
                            new FilterDescriptor(this._column.FilterMemberPath, FilterOperator.IsEqualTo, item.Text));
                    }
                    else
                    {
                        filterDescriptors.Add(
                            new FilterDescriptor(this._column.FilterMemberPath, FilterOperator.IsEqualTo, item.Id));
                    }
                }
            }
            this._filter1.FilterDescriptors.AddRange(filterDescriptors);

            // Check if all item is selected
            if (selectedItems.Count() == this.ItemsSource.Cast<FilteringDataItem>().Count())
            {
                IsSelectAll = true;
            }
            else
            {
                IsSelectAll = false;
            }

            this._column.DataControl.FilterDescriptors.ResumeNotifications();
            this.IsActive = true;
            this.IsItemSelect = false;
        }
 protected DataSourceFilterDescriptorBuilderBase(CompositeFilterDescriptor descriptor)
 {
     Descriptor = descriptor;
 }
        /// <summary>
        /// The create filters 2.
        /// </summary>
        private void CreateFiltersForTextFieldFilter()
        {
            // Filter text
            this._column.DataControl.FilterDescriptors.SuspendNotifications();
            if (this._filter2 == null)
            {
                this._filter2 = new CompositeFilterDescriptor();
                this._filter2.LogicalOperator = FilterCompositionLogicalOperator.Or;
                ((CompositeFilterDescriptor)this._column.DataControl.FilterDescriptors[1]).FilterDescriptors.Add(this._filter2);
            }
            bool isValidValue = IsNumber ? (!string.IsNullOrEmpty(NumberInputValue1) && !string.IsNullOrEmpty(NumberInputValue2)) : 
                                           (!string.IsNullOrEmpty(TextInputValue1) && !string.IsNullOrEmpty(TextInputValue2));
            if (LocalSelectedLogicalOperator.HasValue && this.LocalSelectedOperator1.HasValue && this.LocalSelectedOperator2.HasValue
                && isValidValue)
            {
                this.SelectedLogicalOperator = LocalSelectedLogicalOperator;
                this._filter2.LogicalOperator = LocalSelectedLogicalOperator.Value;
            }

            this._filter2.FilterDescriptors.Clear();

            if (this.LocalSelectedOperator1.HasValue && !string.IsNullOrEmpty(NumberInputValue1))
            {
                this.SelectedOperator1 = this.LocalSelectedOperator1;
                if (IsNumber)
                {
                    this.NumberValue1 = int.Parse(this.NumberInputValue1);
                    this._filter2.FilterDescriptors.Add(new FilterDescriptor(this._column.FilterMemberPath, this.SelectedOperator1.Value, NumberValue1));
                }
               
            }

            if (this.LocalSelectedOperator1.HasValue && !string.IsNullOrEmpty(TextInputValue1))
            {
                this.SelectedOperator1 = this.LocalSelectedOperator1;
                this.TextValue1 = this.TextInputValue1;
                this._filter2.FilterDescriptors.Add(new FilterDescriptor(this._column.FilterMemberPath, this.SelectedOperator1.Value, TextValue1));
            }

            if (this.LocalSelectedOperator2.HasValue && !string.IsNullOrEmpty(NumberInputValue2))
            {
                this.SelectedOperator2 = this.LocalSelectedOperator2;
                this.NumberValue2 = int.Parse(NumberInputValue2);
                this._filter2.FilterDescriptors.Add(new FilterDescriptor(this._column.FilterMemberPath, this.SelectedOperator2.Value, NumberValue2));

            }

            if (this.LocalSelectedOperator2.HasValue && !string.IsNullOrEmpty(TextInputValue2))
            {
                this.SelectedOperator2 = this.LocalSelectedOperator2;
                this.TextValue2 = this.TextInputValue2;
                this._filter2.FilterDescriptors.Add(new FilterDescriptor(this._column.FilterMemberPath, this.SelectedOperator2.Value, TextValue2));
            }

            this._column.DataControl.FilterDescriptors.ResumeNotifications();

            this.IsActive = true;

        }
        protected GridFilterDescriptorBuilderBase(CompositeFilterDescriptor descriptor)
        {
            Guard.IsNotNull(descriptor, "descriptor");

            Descriptor = descriptor;
        }
        /// <summary>
        /// The prepare.
        /// </summary>
        /// <param name="columnToPrepare">
        /// The column to prepare.
        /// </param>
        public void Prepare(Telerik.Windows.Controls.GridViewColumn columnToPrepare)
        {
            this._column = columnToPrepare as GridViewBoundColumnBase;

            this.LocalSelectedLogicalOperator = this.SelectedLogicalOperator;
            if (this.SelectedOperator1.HasValue)
            {
                this.LocalSelectedOperator1 = this.SelectedOperator1.ToString();
            }

            this.LocalSelectedOperator2 = this.SelectedOperator2.ToString();

            this.NumberInputValue1 = this.NumberValue1.HasValue ? this.NumberValue1.ToString() : null;
            this.NumberInputValue2 = this.NumberValue2.HasValue ? this.NumberValue2.ToString() : null;

            foreach ( CompositeFilterDescriptor item in ((CompositeFilterDescriptor)this._column.DataControl.FilterDescriptors[1]).FilterDescriptors)
            {
                if (item.FilterDescriptors.Count > 0)
                {
                    if (((FilterDescriptor)item.FilterDescriptors[0]).Member == this._column.FilterMemberPath)
                    {
                        this._filter = item;
                        break;
                    }
                }
            }
        }
Ejemplo n.º 50
0
        private void CreateFilters()
        {
            this._Column.DataControl.FilterDescriptors.SuspendNotifications();
            if (this._Filter == null)
            {
                this._Filter = new CompositeFilterDescriptor();
                this._Filter.LogicalOperator = FilterCompositionLogicalOperator.Or;
                ((CompositeFilterDescriptor)this._Column.DataControl.FilterDescriptors[1]).FilterDescriptors.Add(this._Filter);
            }

            this._Filter.FilterDescriptors.Clear();
            foreach (SelectListViewModel item in this.ItemsSource)
            {
                if (item.IsSelected)
                {
                    if (this._Column.DataMemberBinding.Path.Path == this._Column.FilterMemberPath)
                    {
                        this._Filter.FilterDescriptors.Add(new FilterDescriptor(this._Column.FilterMemberPath,
                            FilterOperator.IsEqualTo, item.Text));
                    }
                    else
                    {
                        this._Filter.FilterDescriptors.Add(new FilterDescriptor(this._Column.FilterMemberPath,
                            FilterOperator.IsEqualTo, item.Id));
                    }
                }
            }
            this._Column.DataControl.FilterDescriptors.ResumeNotifications();
            this.IsActive = true; 
        }
        /// <summary>
        ///     Filters the pipes in the data grid
        /// </summary>
        private void ProcessSearchFilter()
        {
            View.TelerikGrid.FilterDescriptors.Clear(); //First remove all the old filters

            if (SelectedDistributionList.Name != "All")
            {
                //order is important here: apply filter first, raise property changed, then loop thru ans set checked = true
                CompositeFilterDescriptor distributionListAndFilter = new CompositeFilterDescriptor();
                List<int> distributionListUsers = new List<int>();
                SelectedDistributionList.Distributions.ForEach(x => distributionListUsers.Add(x.UserId));
                distributionListAndFilter.FilterDescriptors.Add(new FilterDescriptor("Id", FilterOperator.IsContainedIn, distributionListUsers, false));
                View.TelerikGrid.FilterDescriptors.Add(distributionListAndFilter);
            }

            if (SelectedRole.Name != "All")
            {
                //order is important here: apply filter first, raise property changed, then loop thru ans set checked = true
                CompositeFilterDescriptor roleFilter = new CompositeFilterDescriptor();
                roleFilter.FilterDescriptors.Add(new FilterDescriptor("RoleId", FilterOperator.IsEqualTo, SelectedRole.Id, false));
                View.TelerikGrid.FilterDescriptors.Add(roleFilter);
            }

            if (!string.IsNullOrEmpty(SearchKeyword))
            {
                CompositeFilterDescriptor textOrFilter = new CompositeFilterDescriptor {LogicalOperator = FilterCompositionLogicalOperator.Or};
                textOrFilter.FilterDescriptors.Add(new FilterDescriptor("FirstName", FilterOperator.Contains, SearchKeyword, false));
                textOrFilter.FilterDescriptors.Add(new FilterDescriptor("LastName", FilterOperator.Contains, SearchKeyword, false));
                textOrFilter.FilterDescriptors.Add(new FilterDescriptor("JobTitle", FilterOperator.Contains, SearchKeyword, false));
                View.TelerikGrid.FilterDescriptors.Add(textOrFilter);
            }
        }
Ejemplo n.º 52
0
        /// <summary>
        ///     初始化ViewModel
        ///     <remarks>
        ///         统一在此处创建并注册CollectionView集合。
        ///     </remarks>
        /// </summary>
        private void InitializeVM()
        {
            Requests = _service.CreateCollection(_context.Requests.Expand(p => p.RelatedDocs), o => o.ApprovalHistories,
                o => o.RelatedDocs);
            var cfd = new CompositeFilterDescriptor {LogicalOperator = FilterCompositionLogicalOperator.And};
            var requestDescriptor = new FilterDescriptor("Title", FilterOperator.IsNotEqualTo, "指标飞机申请(系统添加)");
            cfd.FilterDescriptors.Add(requestDescriptor);
            var statusDateDescriptor = new FilterDescriptor("Status", FilterOperator.IsLessThan, (int) RequestStatus.已审批);
            cfd.FilterDescriptors.Add(statusDateDescriptor);
            Requests.FilterDescriptors.Add(cfd);
            Requests.LoadedData += (o, e) =>
            {
                if (SelRequest == null)
                    SelRequest = Requests.FirstOrDefault();
            };
            _service.RegisterCollectionView(Requests);

            Annuals = new QueryableDataServiceCollectionView<AnnualDTO>(_context, _context.Annuals);
            Annuals.LoadedData += (sender, e) =>
            {
                if (Annuals.Count != 0 && Annuals.FirstOrDefault(p => p.IsOpen) != null)
                {
                    _planDescriptor.Value = Annuals.First(p => p.IsOpen).Year;
                    if (!Plans.AutoLoad)
                        Plans.AutoLoad = true;
                    else
                        Plans.Load(true);
                    RefreshCommandState();
                }
            };

            Plans = new QueryableDataServiceCollectionView<PlanDTO>(_context, _context.Plans);
            _planDescriptor = new FilterDescriptor("Year", FilterOperator.IsEqualTo, -1);
            var sort = new SortDescriptor {Member = "VersionNumber", SortDirection = ListSortDirection.Ascending};
            Plans.SortDescriptors.Add(sort);
            Plans.FilterDescriptors.Add(_planDescriptor);
            Plans.LoadedData += (sender, e) =>
            {
                var curPlan = Plans.OrderBy(p => p.VersionNumber).LastOrDefault();
                if (curPlan != null)
                {
                    _planHistoryDescriptor.Value = curPlan.Id;
                    if (!CurPlanHistories.AutoLoad)
                        CurPlanHistories.AutoLoad = true;
                    else
                        CurPlanHistories.Load(true);
                }
                RefreshCommandState();
                _approvalHistoryCaches = new List<ApprovalHistoryCache>();
            };

            CurPlanHistories = _service.CreateCollection(_context.PlanHistories);
            _planHistoryDescriptor = new FilterDescriptor("PlanId", FilterOperator.IsEqualTo, Guid.Empty);
            var group = new GroupDescriptor {Member = "CanRequest", SortDirection = ListSortDirection.Ascending};
            CurPlanHistories.GroupDescriptors.Add(group);
            CurPlanHistories.FilterDescriptors.Add(_planHistoryDescriptor);
            _service.RegisterCollectionView(CurPlanHistories);

            PlanAircrafts = _service.CreateCollection(_context.PlanAircrafts);
            _service.RegisterCollectionView(PlanAircrafts);
        }
        /// <summary>
        ///     Filters the users in the data grid
        /// </summary>
        private void ProcessSearchFilter()
        {
            var compositeFilter = new CompositeFilterDescriptor();
            var roleFilter = new CompositeFilterDescriptor();

            //AreaId
            if (mRole != null && mRole.Name != "All")
            {
                roleFilter.FilterDescriptors.Add(new FilterDescriptor("Role.Id", FilterOperator.IsEqualTo, mRole.Id, false));
            }

            var text = mKeyword;
            var textArray = text.Split(' ');

            //Add custom entered search text filters
            foreach (var searchText in textArray)
            {
                if (!String.IsNullOrEmpty(searchText))
                {
                    compositeFilter.LogicalOperator = FilterCompositionLogicalOperator.Or;
                    compositeFilter.FilterDescriptors.Add(new FilterDescriptor("FirstName", FilterOperator.Contains, searchText, false));
                    compositeFilter.FilterDescriptors.Add(new FilterDescriptor("LastName", FilterOperator.Contains, searchText, false));
                }
            }

            //Apply the Filters
            View.UsersGrid.FilterDescriptors.Clear(); //First remove all the old filters
            View.UsersGrid.FilterDescriptors.Add(compositeFilter);
            View.UsersGrid.FilterDescriptors.Add(roleFilter);
        }
Ejemplo n.º 54
0
        private void FillEmployeeCombo()
        {
            

            this.Invoke((MethodInvoker)delegate
            {
                this.EmployeeComboBox.MultiColumnComboBoxElement.DropDownWidth = 500;

                this.EmployeeComboBox.AutoFilter = true;
                this.EmployeeComboBox.ValueMember = "ID";
                this.EmployeeComboBox.DisplayMember = "EmployeeName";
            });
            Operation.BeginOperation(this);
            var q = EmployeeCmd.GetAll();
            Operation.EndOperation(this);
            this.Invoke((MethodInvoker)delegate
            {
                EmployeeComboBox.DataSource = q;
                this.EmployeeComboBox.AutoFilter = true;
                CompositeFilterDescriptor compositeFilter = new CompositeFilterDescriptor();
                FilterDescriptor empname = new FilterDescriptor("EmployeeName", FilterOperator.Contains, "");
                FilterDescriptor empNumber = new FilterDescriptor("EmployeejobNumber", FilterOperator.Contains, "");
                compositeFilter.FilterDescriptors.Add(empname);
                compositeFilter.FilterDescriptors.Add(empNumber);
                compositeFilter.LogicalOperator = FilterLogicalOperator.Or;

                this.EmployeeComboBox.EditorControl.FilterDescriptors.Add(compositeFilter);
                ///
                myContractId = TragetContract.ID;
                this.EmployeeComboBox.Text = TragetContract.Employee.EmployeeName;
                this.StartDateTimePicker.Text = TragetContract.StartDate.ToString();
                this.EndDateTimePicker.Text = TragetContract.EndDate.ToString();
                SalaryTextBox.Text = TragetContract.SelaryAmount.ToString();
                this.TotaltextBox.Text = TragetContract.TotalSalary.ToString();
                this.StatusDropDownList.Text = TragetContract.Status.ToString();
            });
            //fillText
            
            

            th.Abort();



        }
        private void CreateFilters()
        {
            string dataMember = this.column.DataMemberBinding.Path.Path;

            this.compositeFilter = new CompositeFilterDescriptor();

            this.fromFilter = new Telerik.Windows.Data.FilterDescriptor(dataMember
                , Telerik.Windows.Data.FilterOperator.IsGreaterThanOrEqualTo
                , null);
            this.compositeFilter.FilterDescriptors.Add(this.fromFilter);

            this.toFilter = new Telerik.Windows.Data.FilterDescriptor(dataMember
                , Telerik.Windows.Data.FilterOperator.IsLessThanOrEqualTo
                , null);
            this.compositeFilter.FilterDescriptors.Add(this.toFilter);
        }
Ejemplo n.º 56
0
        public void Prepare(Telerik.Windows.Controls.GridViewColumn columnToPrepare)
        {
            this._Column = columnToPrepare as GridViewBoundColumnBase;

            if (this._Column == null)
            {
                return;
            }

            this.TitleTextBlock.Text = this.Title;
            if (this.ItemsSource == null)
            {
                return;
            }
            foreach (SelectListViewModel item in this.ItemsSource)
            {
                ((ObservableModel)item).PropertyChanged -= this.SelectFilter_PropertyChanged;
                ((ObservableModel)item).PropertyChanged += this.SelectFilter_PropertyChanged;
            }

            foreach (CompositeFilterDescriptor item in ((CompositeFilterDescriptor)this._Column.DataControl.FilterDescriptors[1]).FilterDescriptors)
            {
                if (item.FilterDescriptors.Count > 0)
                {
                    if (((FilterDescriptor)item.FilterDescriptors[0]).Member == this._Column.FilterMemberPath)
                    {
                        this._Filter = item;
                        break;
                    }
                }
            }
        }
        // This method initially creates all the hierarchy filters required
        private void CreateFilterDescriptor()
        {
            _regionHierarchyFilter = new DistinctHierarchyValuesFilterDescriptor("RegionId");
            _divisionHierarchyFilter = new DistinctHierarchyValuesFilterDescriptor("DivisionId");

            _filters = new CompositeFilterDescriptor { LogicalOperator = FilterCompositionLogicalOperator.Or };
        }
        private void ProcessSearchFilter()
        {
            View.TelerikGrid.FilterDescriptors.Clear(); //First remove all the old filters

            if (SelectedBaseEquipmentComponentType != null && SelectedBaseEquipmentComponentType.Name != ALL && mEquipmentIds.Any())
            {
                CompositeFilterDescriptor filter = new CompositeFilterDescriptor();
                filter.FilterDescriptors.Add(new FilterDescriptor("EquipmentId", FilterOperator.IsContainedIn, mEquipmentIds, false));
                filter.FilterDescriptors.Add(new FilterDescriptor("EquipmentType.Id", FilterOperator.IsEqualTo, SelectedDiscipline.Id, false));
                View.TelerikGrid.FilterDescriptors.Add(filter);
            }

            //Keyword
            if (!string.IsNullOrEmpty(View.KeywordTextBox.Text.Trim()))
            {
                CompositeFilterDescriptor orFilter = new CompositeFilterDescriptor { LogicalOperator = FilterCompositionLogicalOperator.Or };
                string searchText = View.KeywordTextBox.Text;
                orFilter.FilterDescriptors.Add(new FilterDescriptor("Name", FilterOperator.Contains, searchText, false));
                orFilter.FilterDescriptors.Add(new FilterDescriptor("Description", FilterOperator.Contains, searchText, false));
                View.TelerikGrid.FilterDescriptors.Add(orFilter);
            }

            //EquipmentType
            if (SelectedDiscipline != null && SelectedDiscipline.Name != ALL)
            {
                CompositeFilterDescriptor filter = new CompositeFilterDescriptor();
                filter.FilterDescriptors.Add(new FilterDescriptor("EquipmentType.Id", FilterOperator.IsEqualTo, SelectedDiscipline.Id, false));
                View.TelerikGrid.FilterDescriptors.Add(filter);
            }

            //Base EquipmentType
            if (SelectedBaseEquipmentType != null && SelectedBaseEquipmentType.Name != ALL)
            {
                CompositeFilterDescriptor filter = new CompositeFilterDescriptor();
                filter.FilterDescriptors.Add(new FilterDescriptor("EquipmentSubTypeId", FilterOperator.IsEqualTo, SelectedBaseEquipmentType.Id, false));
                View.TelerikGrid.FilterDescriptors.Add(filter);
            }

            //Manufacturer
            if (SelectedManufacturer != null && SelectedManufacturer.Name != ALL)
            {
                CompositeFilterDescriptor filter = new CompositeFilterDescriptor();
                filter.FilterDescriptors.Add(new FilterDescriptor("Manufacturers", FilterOperator.Contains, SelectedManufacturer.Name, false));
                View.TelerikGrid.FilterDescriptors.Add(filter);
            }

            //Model
            if (SelectedModel != null && SelectedModel.Name != ALL)
            {
                CompositeFilterDescriptor filter = new CompositeFilterDescriptor();
                filter.FilterDescriptors.Add(new FilterDescriptor("Models", FilterOperator.Contains, SelectedModel.Name, false));
                View.TelerikGrid.FilterDescriptors.Add(filter);
            }

            ////UpperEquipment
            //if (SelectedUpperEquipment != null && SelectedUpperEquipment.Name != ALL)
            //{
            //    CompositeFilterDescriptor filter = new CompositeFilterDescriptor();
            //    filter.FilterDescriptors.Add(new FilterDescriptor("UpperEquipments", FilterOperator.Contains, SelectedUpperEquipment.Name, false));
            //    View.TelerikGrid.FilterDescriptors.Add(filter);
            //}
        }
Ejemplo n.º 59
0
        private void FillComboBox()
        {  ///GetActivityByProjectID
           ///
            Operation.BeginOperation(this);

            this.Invoke((MethodInvoker)delegate
            {
                this.UserListComboBox.MultiColumnComboBoxElement.DropDownWidth = 500;

                this.ProjectCombo.MultiColumnComboBoxElement.DropDownWidth = 300;


                //User
                this.UserListComboBox.AutoFilter = true;
                this.UserListComboBox.ValueMember = "ID";
                this.UserListComboBox.DisplayMember = "Employee.EmployeeName";

                ///
                //project
                this.ProjectCombo.AutoFilter = true;
                this.ProjectCombo.ValueMember = "ID";
                this.ProjectCombo.DisplayMember = "ProjectName";
            });

            var q = UsersCmd.GetAllUsersToProjects();
            var q1=ProjectProfileCmd.GetAllProjects();
            this.Invoke((MethodInvoker)delegate
            {
                //FillUser
                UserListComboBox.DataSource = q;
                this.UserListComboBox.AutoFilter = true;
                CompositeFilterDescriptor compositeFilter = new CompositeFilterDescriptor();
                FilterDescriptor empname = new FilterDescriptor("Employee.EmployeeName", FilterOperator.Contains, "");
                FilterDescriptor empNumber = new FilterDescriptor("Employee.EmployeejobNumber", FilterOperator.Contains, "");
                compositeFilter.FilterDescriptors.Add(empname);
                compositeFilter.FilterDescriptors.Add(empNumber);
                compositeFilter.LogicalOperator = FilterLogicalOperator.Or;

                this.UserListComboBox.EditorControl.FilterDescriptors.Add(compositeFilter);
              
                    ///
                //// fill ProjectCombo
            ProjectCombo.DataSource = q1;
            FilterDescriptor filter1 = new FilterDescriptor();
            filter1.PropertyName = this.ProjectCombo.DisplayMember;
            filter1.Operator = FilterOperator.Contains;
            this.ProjectCombo.EditorControl.MasterTemplate.FilterDescriptors.Add(filter1);
           

            });
            Operation.EndOperation(this);
            th.Abort();


          
          
          
          
          
          




        }
        /// <summary>
        ///     Filters the pipes in the data grid
        /// </summary>
        private void ProcessSearchFilter()
        {
            View.TelerikGrid.FilterDescriptors.Clear(); //First remove all the old filters

            if (SelectedCategory.Name != "All")
            {
                CompositeFilterDescriptor compositeFilter = new CompositeFilterDescriptor();
                compositeFilter.FilterDescriptors.Add(new FilterDescriptor("IssueCategoryId", FilterOperator.IsEqualTo, SelectedCategory.Id, false));
                View.TelerikGrid.FilterDescriptors.Add(compositeFilter);
            }

            if (SelectedType.Name != "All")
            {
                CompositeFilterDescriptor compositeFilter = new CompositeFilterDescriptor();
                compositeFilter.FilterDescriptors.Add(new FilterDescriptor("IssueTypeId", FilterOperator.IsEqualTo, SelectedType.Id, false));
                View.TelerikGrid.FilterDescriptors.Add(compositeFilter);
            }

            if (!string.IsNullOrEmpty(SearchKeyword))
            {
                CompositeFilterDescriptor textOrFilter = new CompositeFilterDescriptor {LogicalOperator = FilterCompositionLogicalOperator.Or};
                textOrFilter.FilterDescriptors.Add(new FilterDescriptor("Name", FilterOperator.Contains, SearchKeyword, false));
                textOrFilter.FilterDescriptors.Add(new FilterDescriptor("Description", FilterOperator.Contains, SearchKeyword, false));
                View.TelerikGrid.FilterDescriptors.Add(textOrFilter);
            }
        }