예제 #1
0
        public SearchDescriptor <T> GetSearchDescriptor()
        {
            var s = new SearchDescriptor <T>()
                    .Index(Indices)
                    .Skip(Skip ?? 0)
                    .Take(Take ?? 10)
                    .Aggregations(a => BucketFields.GetBucketAggreagationDescriptor <T>())
                    .Query(q => FilterFields.GetQueryDesctiptor <T>())
                    .Source(t => ReturnFields.GetSourceFilterDescriptor <T>())
                    .Sort(s => SortFields.GetSortDescriptor <T>());

            return(s);
        }
예제 #2
0
        private void txtFilter_EditValueChanged(object sender, EventArgs e)
        {
            DataView dv = GetDataView();

            if (dv == null)
            {
                return;
            }

            string strFilter = "";

            if (FilterFields == "")
            {
                foreach (DataColumn dc in dv.Table.Columns)
                {
                    if (dc.DataType.ToString() == "System.String")
                    {
                        strFilter = strFilter + "(" + dc.ColumnName + " like '" + txtFilter.Text + "%') or";
                    }
                }

                strFilter    = strFilter.Substring(0, strFilter.Length - 2);
                dv.RowFilter = strFilter;
            }

            else
            {
                string[] Fields = FilterFields.Split(';');

                foreach (string s in Fields)
                {
                    if (s == "F_Spell")
                    {
                        if (dv.Table.Columns.Contains(s) == false)
                        {
                            continue;
                        }
                    }
                    strFilter = strFilter + "(" + s + " like '" + txtFilter.Text + "%') or";
                }

                if (strFilter != "")
                {
                    strFilter    = strFilter.Substring(0, strFilter.Length - 2);
                    dv.RowFilter = strFilter;
                }
            }
        }
예제 #3
0
        protected override void EndProcessing()
        {
            var chart = new Chart
            {
                Id              = Id,
                Labels          = Labels,
                Title           = Title,
                ChartType       = Type,
                Callback        = GenerateCallback(Id),
                Options         = Options,
                Width           = Width,
                Height          = Height,
                AutoRefresh     = AutoRefresh,
                RefreshInterval = RefreshInterval,
                BackgroundColor = BackgroundColor?.HtmlColor,
                FontColor       = FontColor?.HtmlColor,
                Links           = Links,
                FilterFields    = FilterFields?.Invoke().Select(m => m.BaseObject).OfType <Field>().ToArray()
            };

            Endpoint callback = null;

            var scriptBlock = OnClick as ScriptBlock;

            if (scriptBlock != null)
            {
                callback = GenerateCallback(Id + "onClick", scriptBlock, null);
            }
            else
            {
                var psobject = OnClick as PSObject;
                callback = psobject?.BaseObject as Endpoint;
            }

            chart.Clickable      = callback != null;
            chart.ChildEndpoints = new[] { callback };
            Log.Debug(JsonConvert.SerializeObject(chart));

            WriteObject(chart);
        }
예제 #4
0
        public static SqlQuery ApplyFilters(this SqlQuery query,
                                            BasicFilterBase filter,
                                            IList <FilterLine> filterLines,
                                            Row row,
                                            Func <BasicFilter, BaseCriteria> processCriteria,
                                            FilterFields filterFields)
        {
            if (Object.ReferenceEquals(filter, null) &&
                (filterLines == null ||
                 filterLines.Count == 0))
            {
                return(query);
            }

            var converter = new BasicFilterStringConverter(query, row, processCriteria, filterFields);

            BaseCriteria where;

            if (!Object.ReferenceEquals(filter, null))
            {
                where = converter.Convert(filter);
                if (!where.IsEmpty)
                {
                    query.Where(where);
                }
            }

            if (filterLines != null &&
                filterLines.Count > 0)
            {
                var linesFilter = filterLines.ToBasicFilter();
                where = converter.Convert(linesFilter);
                if (!where.IsEmpty)
                {
                    query.Where(where);
                }
            }
            return(query);
        }
예제 #5
0
 public void ClearFieldFilters()
 {
     FilterFields?.Clear();
     PleaseClearColumnFilters?.Invoke(this, null);
 }
예제 #6
0
        public IList <DisponibilizationProcess> FilterProcesses([FromServices] DataContext context, [FromBody] FilterFields model)
        {
            var processes = context.DisponibilizationProcesses
                            .AsNoTracking()
                            .Include(x => x.Applicant)
                            .ThenInclude(y => y.Properties)
                            .ThenInclude(z => z.PersonProperties)
                            .Include(x => x.TechnicalAnalysis)
                            .ThenInclude(y => y.Analyses)
                            .Include(x => x.Geometries)
                            .Include(x => x.Adequacies)
                            .ToList();

            List <DisponibilizationProcess> filteredProcesses = new List <DisponibilizationProcess>();

            if (model.Value != null && model.Value != "")
            {
                if (model.Entity == "DisponibilizationApplicant")
                {
                    foreach (DisponibilizationProcess process in processes)
                    {
                        var applicant = process.Applicant;

                        PropertyInfo[] properties = applicant.GetType().GetProperties();

                        properties = properties
                                     .Where(x => (x.Name == model.Field &&
                                                  x.GetValue(applicant) != null) && x.GetValue(applicant).ToString().ToLower()
                                            .Contains(model.Value.ToLower()))
                                     .ToArray();

                        if (properties.Length > 0)
                        {
                            filteredProcesses.Add(process);
                        }
                    }
                }

                if (model.Entity == "DisponibilizationProperty")
                {
                    foreach (DisponibilizationProcess process in processes)
                    {
                        var applicantProperties = process.Applicant.Properties;

                        foreach (DisponibilizationProperty property in applicantProperties)
                        {
                            PropertyInfo[] properties = property.GetType().GetProperties();

                            properties = properties
                                         .Where(x => (x.Name == model.Field &&
                                                      x.GetValue(property) != null) && x.GetValue(property).ToString().ToLower()
                                                .Contains(model.Value.ToLower()))
                                         .ToArray();

                            if (properties.Length > 0)
                            {
                                filteredProcesses.Add(process);
                                break;
                            }
                        }
                    }
                }

                if (model.Entity == "DisponibilizationPersonProperty")
                {
                    foreach (DisponibilizationProcess process in processes)
                    {
                        var applicantProperties = process.Applicant.Properties;

                        foreach (DisponibilizationProperty property in applicantProperties)
                        {
                            var personProperties = property.PersonProperties;

                            foreach (DisponibilizationPersonProperty personProperty in personProperties)
                            {
                                PropertyInfo[] properties = personProperty.GetType().GetProperties();

                                properties = properties
                                             .Where(x => (x.Name == model.Field &&
                                                          x.GetValue(personProperty) != null) && x.GetValue(personProperty).ToString().ToLower()
                                                    .Contains(model.Value.ToLower()))
                                             .ToArray();

                                if (properties.Length > 0)
                                {
                                    filteredProcesses.Add(process);
                                    break;
                                }
                            }
                        }
                    }
                }

                if (model.Entity == "DisponibilizationTechnicalAnalysis")
                {
                    foreach (DisponibilizationProcess process in processes)
                    {
                        var technicalAnalysis = process.TechnicalAnalysis;

                        PropertyInfo[] properties = technicalAnalysis.GetType().GetProperties();

                        properties = properties
                                     .Where(x => (x.Name == model.Field &&
                                                  x.GetValue(technicalAnalysis) != null) && x.GetValue(technicalAnalysis).ToString().ToLower()
                                            .Contains(model.Value.ToLower()))
                                     .ToArray();

                        if (properties.Length > 0)
                        {
                            filteredProcesses.Add(process);
                        }
                    }
                }

                if (model.Entity == "DisponibilizationAnalysis")
                {
                    foreach (DisponibilizationProcess process in processes)
                    {
                        var analyses = process.TechnicalAnalysis.Analyses;

                        foreach (DisponibilizationAnalysis analysis in analyses)
                        {
                            PropertyInfo[] properties = analysis.GetType().GetProperties();

                            properties = properties
                                         .Where(x => (x.Name == model.Field &&
                                                      x.GetValue(analysis) != null) && x.GetValue(analysis).ToString().ToLower()
                                                .Contains(model.Value.ToLower()))
                                         .ToArray();

                            if (properties.Length > 0)
                            {
                                filteredProcesses.Add(process);
                                break;
                            }
                        }
                    }
                }

                if (model.Entity == "DisponibilizationAdequacy")
                {
                    foreach (DisponibilizationProcess process in processes)
                    {
                        var adequacies = process.Adequacies;

                        foreach (DisponibilizationAdequacy adequacy in adequacies)
                        {
                            PropertyInfo[] properties = adequacy.GetType().GetProperties();

                            properties = properties
                                         .Where(x => (x.Name == model.Field &&
                                                      x.GetValue(adequacy) != null) && x.GetValue(adequacy).ToString().ToLower()
                                                .Contains(model.Value.ToLower()))
                                         .ToArray();

                            if (properties.Length > 0)
                            {
                                filteredProcesses.Add(process);
                                break;
                            }
                        }
                    }
                }

                if (model.Entity == "DisponibilizationGeometry")
                {
                    foreach (DisponibilizationProcess process in processes)
                    {
                        var geometries = process.Geometries;

                        foreach (DisponibilizationGeometry geometry in geometries)
                        {
                            PropertyInfo[] properties = geometry.GetType().GetProperties();

                            properties = properties
                                         .Where(x => (x.Name == model.Field &&
                                                      x.GetValue(geometry) != null) && x.GetValue(geometry).ToString().ToLower()
                                                .Contains(model.Value.ToLower()))
                                         .ToArray();

                            if (properties.Length > 0)
                            {
                                filteredProcesses.Add(process);
                                break;
                            }
                        }
                    }
                }
            }

            if (filteredProcesses.Count > 0)
            {
                processes.Clear();
                filteredProcesses.ForEach(val => { processes.Add(val); });
            }
            else if (model.Value != null)
            {
                if (model.Value.Length > 0 && filteredProcesses.Count == 0)
                {
                    processes.Clear();
                }
            }

            if (!String.IsNullOrEmpty(model.Task))
            {
                processes = processes.Where(x => x.Task == model.Task).ToList <DisponibilizationProcess>();
            }

            if (!String.IsNullOrEmpty(model.Protocol))
            {
                processes = processes.Where(x => x.Protocol == model.Protocol).ToList <DisponibilizationProcess>();
            }

            if (!String.IsNullOrEmpty(model.Condition))
            {
                processes = processes.Where(x => x.Condition == model.Condition).ToList <DisponibilizationProcess>();
            }

            if (model.DateRange != null)
            {
                processes = processes.Where(x => x.ModifiedOn > model.DateRange[0] && x.ModifiedOn < model.DateRange[1]).ToList <DisponibilizationProcess>();
            }

            return(processes);
        }
예제 #7
0
 public bool HasFilterFields()
 {
     return(FilterFields != null && FilterFields.Any());
 }
        public IList <AdoptionProcess> FilterProcesses([FromServices] DataContext context, [FromBody] FilterFields model)
        {
            var processes = context.AdoptionProcesses
                            .AsNoTracking()
                            .Include(x => x.AdoptionApplicant)
                            .Include(x => x.AdoptionApplicant.AdoptionInterlocutor)
                            .Include(x => x.AdoptionApplicant.AdoptionObligation)
                            .Include(x => x.AdoptionTechnicalAnalysis)
                            .Include(x => x.AdoptionTechnicalAnalysis.Analyses)
                            .Include(x => x.AdoptionTechnicalAnalysis.Properties)
                            .Include(x => x.AdoptionAdequacy)
                            .Include(x => x.AdoptionAdequacy.Adequacies)
                            .ToList();

            List <AdoptionProcess> filteredProcesses = new List <AdoptionProcess>();

            if (model.Value != null && model.Value != "")
            {
                if (model.Entity == "AdoptionApplicant")
                {
                    foreach (AdoptionProcess process in processes)
                    {
                        var applicant = process.AdoptionApplicant;

                        PropertyInfo[] properties = applicant.GetType().GetProperties();

                        properties = properties
                                     .Where(x => (x.Name == model.Field &&
                                                  x.GetValue(applicant) != null) && x.GetValue(applicant).ToString().ToLower()
                                            .Contains(model.Value.ToLower()))
                                     .ToArray();

                        if (properties.Length > 0)
                        {
                            filteredProcesses.Add(process);
                        }
                    }
                }

                if (model.Entity == "AdoptionInterlocutor")
                {
                    foreach (AdoptionProcess process in processes)
                    {
                        var interlocutor = process.AdoptionApplicant.AdoptionInterlocutor;

                        PropertyInfo[] properties = interlocutor.GetType().GetProperties();

                        properties = properties
                                     .Where(x => (x.Name == model.Field &&
                                                  x.GetValue(interlocutor) != null) && x.GetValue(interlocutor).ToString().ToLower()
                                            .Contains(model.Value.ToLower()))
                                     .ToArray();

                        if (properties.Length > 0)
                        {
                            filteredProcesses.Add(process);
                        }
                    }
                }

                if (model.Entity == "AdoptionObligation")
                {
                    foreach (AdoptionProcess process in processes)
                    {
                        var obligation = process.AdoptionApplicant.AdoptionObligation;

                        PropertyInfo[] properties = obligation.GetType().GetProperties();

                        properties = properties
                                     .Where(x => (x.Name == model.Field &&
                                                  x.GetValue(obligation) != null) && x.GetValue(obligation).ToString().ToLower()
                                            .Contains(model.Value.ToLower()))
                                     .ToArray();

                        if (properties.Length > 0)
                        {
                            filteredProcesses.Add(process);
                        }
                    }
                }

                if (model.Entity == "AdoptionAdequacy")
                {
                    foreach (AdoptionProcess process in processes)
                    {
                        var adequacy = process.AdoptionAdequacy;

                        PropertyInfo[] properties = adequacy.GetType().GetProperties();

                        properties = properties
                                     .Where(x => (x.Name == model.Field &&
                                                  x.GetValue(adequacy) != null) && x.GetValue(adequacy).ToString().ToLower()
                                            .Contains(model.Value.ToLower()))
                                     .ToArray();

                        if (properties.Length > 0)
                        {
                            filteredProcesses.Add(process);
                        }
                    }
                }

                if (model.Entity == "AdoptionAdequacyItem")
                {
                    foreach (AdoptionProcess process in processes)
                    {
                        var adequacies = process.AdoptionAdequacy.Adequacies;

                        foreach (AdoptionAdequacyItem adequacyItem in adequacies)
                        {
                            PropertyInfo[] properties = adequacyItem.GetType().GetProperties();

                            properties = properties
                                         .Where(x => (x.Name == model.Field &&
                                                      x.GetValue(adequacyItem) != null) && x.GetValue(adequacyItem).ToString().ToLower()
                                                .Contains(model.Value.ToLower()))
                                         .ToArray();

                            if (properties.Length > 0)
                            {
                                filteredProcesses.Add(process);
                                break;
                            }
                        }
                    }
                }

                if (model.Entity == "AdoptionTechnicalAnalysis")
                {
                    foreach (AdoptionProcess process in processes)
                    {
                        var technicalAnalysis = process.AdoptionTechnicalAnalysis;

                        PropertyInfo[] properties = technicalAnalysis.GetType().GetProperties();

                        properties = properties
                                     .Where(x => (x.Name == model.Field &&
                                                  x.GetValue(technicalAnalysis) != null) && x.GetValue(technicalAnalysis).ToString().ToLower()
                                            .Contains(model.Value.ToLower()))
                                     .ToArray();

                        if (properties.Length > 0)
                        {
                            filteredProcesses.Add(process);
                        }
                    }
                }

                if (model.Entity == "AdoptionAnalysis")
                {
                    foreach (AdoptionProcess process in processes)
                    {
                        var analyses = process.AdoptionTechnicalAnalysis.Analyses;

                        foreach (AdoptionAnalysis analysis in analyses)
                        {
                            PropertyInfo[] properties = analysis.GetType().GetProperties();

                            properties = properties
                                         .Where(x => (x.Name == model.Field &&
                                                      x.GetValue(analysis) != null) && x.GetValue(analysis).ToString().ToLower()
                                                .Contains(model.Value.ToLower()))
                                         .ToArray();

                            if (properties.Length > 0)
                            {
                                filteredProcesses.Add(process);
                                break;
                            }
                        }
                    }
                }

                if (model.Entity == "AdoptionProperty")
                {
                    foreach (AdoptionProcess process in processes)
                    {
                        var AnalysisProperties = process.AdoptionTechnicalAnalysis.Properties;

                        foreach (AdoptionProperty property in AnalysisProperties)
                        {
                            PropertyInfo[] properties = property.GetType().GetProperties();

                            properties = properties
                                         .Where(x => (x.Name == model.Field &&
                                                      x.GetValue(property) != null) && x.GetValue(property).ToString().ToLower()
                                                .Contains(model.Value.ToLower()))
                                         .ToArray();

                            if (properties.Length > 0)
                            {
                                filteredProcesses.Add(process);
                                break;
                            }
                        }
                    }
                }
            }

            if (filteredProcesses.Count > 0)
            {
                processes.Clear();
                filteredProcesses.ForEach(val => { processes.Add(val); });
            }
            else if (model.Value != null)
            {
                if (model.Value.Length > 0 && filteredProcesses.Count == 0)
                {
                    processes.Clear();
                }
            }

            if (!String.IsNullOrEmpty(model.Task))
            {
                processes = processes.Where(x => x.Task == model.Task).ToList <AdoptionProcess>();
            }

            if (!String.IsNullOrEmpty(model.Protocol))
            {
                processes = processes.Where(x => x.Protocol == model.Protocol).ToList <AdoptionProcess>();
            }

            if (!String.IsNullOrEmpty(model.Condition))
            {
                processes = processes.Where(x => x.Condition == model.Condition).ToList <AdoptionProcess>();
            }

            if (model.DateRange != null)
            {
                processes = processes.Where(x => x.ModifiedOn >= model.DateRange[0] && x.ModifiedOn <= model.DateRange[1]).ToList <AdoptionProcess>();
            }

            return(processes);
        }
        public IList <InscriptionProcess> FilterProcesses([FromServices] DataContext context, [FromBody] FilterFields model, string type)
        {
            var processes = context.InscriptionProcesses
                            .AsNoTracking()
                            .Include(x => x.InscriptionResourceTaker)
                            .Include(x => x.InscriptionFinancedEnterprise)
                            .Include(x => x.InscriptionProcessTaskLogs)
                            .Where(x => x.Type == type)
                            .ToList();

            List <InscriptionProcess> filteredProcesses = new List <InscriptionProcess>();

            if (!String.IsNullOrEmpty(model.Value))
            {
                if (model.Entity == "InscriptionProcess")
                {
                    foreach (var process in processes)
                    {
                        PropertyInfo[] properties = process.GetType().GetProperties();

                        properties = properties
                                     .Where(x => (x.Name == model.Field &&
                                                  x.GetValue(process) != null) && x.GetValue(process).ToString().ToLower()
                                            .Contains(model.Value.ToLower()))
                                     .ToArray();

                        if (properties.Length > 0)
                        {
                            filteredProcesses.Add(process);
                        }
                    }
                }

                if (model.Entity == "InscriptionResourceTaker")
                {
                    foreach (var process in processes)
                    {
                        var resourceTaker = process.InscriptionResourceTaker;

                        PropertyInfo[] properties = resourceTaker.GetType().GetProperties();

                        properties = properties
                                     .Where(x => (x.Name == model.Field &&
                                                  x.GetValue(resourceTaker) != null) && x.GetValue(resourceTaker).ToString().ToLower()
                                            .Contains(model.Value.ToLower()))
                                     .ToArray();

                        if (properties.Length > 0)
                        {
                            filteredProcesses.Add(process);
                        }
                    }
                }

                if (model.Entity == "InscriptionFinancedEnterprise")
                {
                    foreach (var process in processes)
                    {
                        var financedEnterprise = process.InscriptionFinancedEnterprise;

                        PropertyInfo[] properties = financedEnterprise.GetType().GetProperties();

                        properties = properties
                                     .Where(x => (x.Name == model.Field &&
                                                  x.GetValue(financedEnterprise) != null) && x.GetValue(financedEnterprise).ToString().ToLower()
                                            .Contains(model.Value.ToLower()))
                                     .ToArray();

                        if (properties.Length > 0)
                        {
                            filteredProcesses.Add(process);
                        }
                    }
                }
            }

            if (filteredProcesses.Count > 0)
            {
                processes.Clear();
                filteredProcesses.ForEach(val => { processes.Add(val); });
            }
            else if (model.Value != null)
            {
                if (model.Value.Length > 0 && filteredProcesses.Count == 0)
                {
                    processes.Clear();
                }
            }

            if (!String.IsNullOrEmpty(model.Task))
            {
                processes = processes.Where(x => x.Task == model.Task).ToList <InscriptionProcess>();
            }

            if (!String.IsNullOrEmpty(model.Protocol))
            {
                processes = processes.Where(x => x.NupProtocol == model.Protocol).ToList <InscriptionProcess>();
            }

            if (!String.IsNullOrEmpty(model.Condition))
            {
                processes = processes.Where(x => x.Status == model.Condition).ToList <InscriptionProcess>();
            }

            if (model.DateRange != null)
            {
                processes = processes.Where(x => x.ModifiedOn >= model.DateRange[0] && x.ModifiedOn <= model.DateRange[1]).ToList <InscriptionProcess>();
            }

            return(processes);
        }