Ejemplo n.º 1
0
        private DataTablesReturnBuilder <T> AddFiltro <TParam>(string nomeColuna, TipoFiltro tipoFiltro, TParam valor)
        {
            string sql = "";

            if (typeof(TParam) == typeof(DateTime) || typeof(TParam) == typeof(DateTime?))
            {
                sql += $"{nomeColuna} {Operador(tipoFiltro)} DateTime({valor:yyyy, MM, dd, HH, mm, ss})";
            }
            else
            {
                switch (tipoFiltro)
                {
                case TipoFiltro.Contem:
                    sql = $"{nomeColuna}.contains(\"{valor}\")";
                    break;

                default:
                    sql += $"{nomeColuna} {Operador(tipoFiltro)} {ProcessaValor(valor.ToString())}";
                    break;
                }
            }

            _listaFiltrada = _listaFiltrada.Where(sql);

            return(this);
        }
Ejemplo n.º 2
0
        public Filtro(TipoFiltro tipo, DateTime fecha)
        {
            this.Tipo      = tipo;
            this.Fecha1    = fecha;
            this.IsChecked = true;
            switch (tipo)
            {
            case TipoFiltro.HORA_MENOR:
                this.Name = "Hora < a " + fecha.ToShortTimeString();
                break;

            case TipoFiltro.HORA_MAYOR:
                this.Name = "Hora > a " + fecha.ToShortTimeString();
                break;

            case TipoFiltro.FECHA_MENOR:
                this.Name = "Fecha < a " + fecha.ToShortDateString();
                break;

            case TipoFiltro.FECHA_MAYOR:
                this.Name = "Fecha > a " + fecha.ToShortDateString();
                break;

            default:
                break;
            }
        }
Ejemplo n.º 3
0
        private void EstablecerTipoDeFiltro()
        {
            cboMes.Enabled         = false;
            deFechaInicial.Enabled = false;
            deFechaFinal.Enabled   = false;

            TipoFiltro tipoFiltroSel = (TipoFiltro)cboTipoFiltro.EditValue;

            switch (tipoFiltroSel)
            {
            case TipoFiltro.Todo:     //todos
                break;

            case TipoFiltro.Mes:    //Mes
                cboMes.Enabled = true;
                break;

            case TipoFiltro.Rango:     //Rango de fecha
                deFechaInicial.Enabled   = true;
                deFechaFinal.Enabled     = true;
                deFechaInicial.EditValue = FiltroConsulta.FechaInicial;
                deFechaFinal.EditValue   = FiltroConsulta.FechaFinal;
                break;
            }
        }
Ejemplo n.º 4
0
        private ICollection <InformacionFiltro> DecodificarFiltro(string filterBy)
        {
            ICollection <InformacionFiltro> filtros = new List <InformacionFiltro>();

            foreach (string condicion in DecodificarParametrosFiltro(filterBy))
            {
                TipoFiltro tipoFiltro = IdentificarTipoFiltro(condicion);
                string[]   campoValor = condicion.Split(new string[] { UtilEnumeradores.IdReducidoFiltro(tipoFiltro) }, StringSplitOptions.None);

                string campo = PrimerCaracterMayuscula(campoValor[0]);
                if (!EntidadContieneAtributo(campo))
                {
                    throw new BaseException("La entidad no contiene el atributo " + campo);
                }

                string valor = campoValor[1];
                if (String.IsNullOrEmpty(valor))
                {
                    throw new BaseException("No se especificó un valor para el campo " + campo);
                }

                TipoOperador tipoOperador = IdentificarTipoOperador(filterBy, condicion);

                filtros.Add(new InformacionFiltro(campo, tipoFiltro, valor, tipoOperador));
            }

            return(filtros);
        }
Ejemplo n.º 5
0
 public InformacionFiltro(String campo, TipoFiltro tipo, Object valor, TipoOperador operador)
 {
     this.Campo    = campo;
     this.Tipo     = tipo;
     this.Valor    = valor;
     this.Operador = operador;
 }
Ejemplo n.º 6
0
 // Constructores.
 protected CmdCargarDataGrid(Form myForm, DataGridView myGrid, TipoFiltro myFiltro, string textoFiltro)
 {
     this.ocurrioError = false;
     this.myForm       = myForm;
     this.myGrid       = myGrid;
     this.myFiltro     = myFiltro;
     this.textoFiltro  = textoFiltro;
 }
Ejemplo n.º 7
0
        public DataTablesReturnBuilder <T> AddFiltro <TParam>(string nomeFiltro, TipoFiltro tipoFiltro)
        {
            if (_request.AdditionalParameters.ContainsKey(nomeFiltro))
            {
                AddFiltro(nomeFiltro, tipoFiltro, _request.Get <TParam>(nomeFiltro));
            }

            return(this);
        }
Ejemplo n.º 8
0
 public void AdicionaParametro(string nome, dynamic valor, TipoFiltro tipo)
 {
     this.Parametros.Add(new ParametroFiltro()
     {
         Nome  = nome,
         Tipo  = tipo,
         Valor = valor
     });
 }
Ejemplo n.º 9
0
        public DataTablesReturnBuilder <T> AddFiltro <TParam>(string nomeFiltro, TipoFiltro tipoFiltro, Func <TParam, bool> condicaoParaAplicarOFiltro)
        {
            if (_request.AdditionalParameters.ContainsKey(nomeFiltro))
            {
                if (condicaoParaAplicarOFiltro(_request.Get <TParam>(nomeFiltro)))
                {
                    return(AddFiltro(nomeFiltro, tipoFiltro, _request.Get <TParam>(nomeFiltro)));
                }
            }

            return(this);
        }
Ejemplo n.º 10
0
 /**
  * Adicionar filtros de busca ao sistema que podem ser os padrões, buscas e por campos.
  * Ex. de filtro padrão.
  * Filtros padrões são aqueles em que o sistema já vai predefinido, mesmo antes o usuário escolher qualquer
  * filtragem, esse filtro vem depois do filtro padrão dentro da classe PHP que acontece antes mesmo desse filtro.
  *
  *      List<KeyValuePair<int, string[]>> Filtros = new List<KeyValuePair<int, string[]>>();
  *      Filtros.Add(new KeyValuePair<int, string[]>(0, new string[4] { "1", "like", "%02%", "1" }));
  *      Filtros.Add(new KeyValuePair<int, string[]>(1, new string[4] { "2", "like",  "%8%", "1" }));
  *      KeyValuePair<int, string[]> ft = new KeyValuePair<int, string[]>(0 , new string[4]{"1","like","%02%","1"});
  *
  */
 public void setFiltros(TipoFiltro Tipo, List <KeyValuePair <int, string[]> > Lst)
 {
     foreach (KeyValuePair <int, string[]> i in Lst)
     {
         ListaFiltrosPadroes.Add(new KeyValuePair <string, string>("sendFiltros[" + (int)Tipo + "][" + i.Key + "][0]", (string)i.Value.GetValue(0)));
         ListaFiltrosPadroes.Add(new KeyValuePair <string, string>("sendFiltros[" + (int)Tipo + "][" + i.Key + "][1]", (string)i.Value.GetValue(1)));
         ListaFiltrosPadroes.Add(new KeyValuePair <string, string>("sendFiltros[" + (int)Tipo + "][" + i.Key + "][2]", (string)i.Value.GetValue(2)));
         ListaFiltrosPadroes.Add(new KeyValuePair <string, string>("sendFiltros[" + (int)Tipo + "][" + i.Key + "][3]", (string)i.Value.GetValue(3)));
     }
     if (ListaFiltrosPadroes.Count > 0)
     {
         EnviarParametros.AddRange(ListaFiltrosPadroes);
     }
 }
Ejemplo n.º 11
0
        public Filtro(TipoFiltro tipo, double intervalo1, double intervalo2)
        {
            this.Tipo       = tipo;
            this.intervalo  = intervalo1;
            this.intervalo2 = intervalo2;
            this.IsChecked  = true;
            switch (tipo)
            {
            case TipoFiltro.INTERVALO_ENTRE:
                this.Name = "Intervalo > a " + intervalo + " y < a " + intervalo2;
                break;

            default:
                break;
            }
        }
Ejemplo n.º 12
0
        string Operador(TipoFiltro tipoFiltro)
        {
            switch (tipoFiltro)
            {
            case TipoFiltro.Igual:
                return("=");

            case TipoFiltro.MaiorOuIgual:
                return(">=");

            case TipoFiltro.MenorOuIgual:
                return("<= ");

            default:
                throw new Exception();
            }
        }
Ejemplo n.º 13
0
 private System.Windows.Media.ImageSource ProcessarQuadro(string arquivo, TipoFiltro tipoFiltro)
 {
     System.Windows.Media.ImageSource imageSource = new BitmapImage();
     if (!string.IsNullOrEmpty(arquivo))
     {
         if (tipoFiltro == TipoFiltro.Limiarizacao)
         {
             imageSource = ToBitmapImage(new Limiarizacao().Aplicar(arquivo));
         }
         else if (tipoFiltro == TipoFiltro.Vizinhanca)
         {
             imageSource = ToBitmapImage(new Vizinhanca().Aplicar(arquivo));
         }
         else if (tipoFiltro == TipoFiltro.Gaussiano)
         {
             imageSource = ToBitmapImage(new Gaussiano(3).Aplicar(arquivo));
         }
         else if (tipoFiltro == TipoFiltro.Media)
         {
             imageSource = ToBitmapImage(new Media(3).Aplicar(arquivo));
         }
         else if (tipoFiltro == TipoFiltro.Mediana)
         {
             imageSource = ToBitmapImage(new Mediana(7).Aplicar(arquivo));
         }
         else if (tipoFiltro == TipoFiltro.Laplaciano)
         {
             imageSource = ToBitmapImage(new Laplaciano().Aplicar(arquivo));
         }
         else if (tipoFiltro == TipoFiltro.Sobel)
         {
             imageSource = ToBitmapImage(new Sobel().Aplicar(arquivo));
         }
         else if (tipoFiltro == TipoFiltro.Prewitt)
         {
             imageSource = ToBitmapImage(new Prewitt().Aplicar(arquivo));
         }
         else if (tipoFiltro == TipoFiltro.Canny)
         {
             imageSource = ToBitmapImage(new Canny().Aplicar(arquivo));
         }
     }
     return(imageSource);
 }
Ejemplo n.º 14
0
        public Filtro(TipoFiltro tipo, double intervalo)
        {
            this.Tipo      = tipo;
            this.intervalo = intervalo;
            this.IsChecked = true;
            switch (tipo)
            {
            case TipoFiltro.INTERVALO_MENOR:
                this.Name = "Intervalo < a " + intervalo;
                break;

            case TipoFiltro.INTERVALO_MAYOR:
                this.Name = "Intervalo > a " + intervalo;
                break;

            default:
                break;
            }
        }
Ejemplo n.º 15
0
        public Filtro(TipoFiltro tipo, DateTime fecha1, DateTime fecha2)
        {
            this.Tipo      = tipo;
            this.Fecha1    = fecha1;
            this.Fecha2    = fecha2;
            this.IsChecked = true;
            switch (tipo)
            {
            case TipoFiltro.HORA_ENTRE:
                this.Name = "Hora > a " + fecha1.ToShortTimeString() + " y < a" + fecha2.ToShortTimeString();
                break;

            case TipoFiltro.FECHA_ENTRE:
                this.Name = "Fecha > a " + fecha1.ToShortDateString() + " y < a" + fecha2.ToShortDateString();
                break;

            default:
                throw new ArgumentException("Los tipos de filtro para 2 fechas son entre");
            }
        }
        private void CargarContratos()
        {
            TipoFiltro myTipo      = TipoFiltro.Todo;
            string     valorFiltro = string.Empty;

            if (this.filtrosComboBox.SelectedIndex == 0)
            {
                myTipo = TipoFiltro.Todo;
            }
            if (this.filtrosComboBox.SelectedIndex == 1)
            {
                myTipo      = TipoFiltro.NumeroContrato;
                valorFiltro = this.valorFiltroTextBox.Text.Trim().ToUpper();
            }
            if (this.filtrosComboBox.SelectedIndex == 2)
            {
                if (!this.ValidaRut())
                {
                    return;
                }
                myTipo      = TipoFiltro.Rut;
                valorFiltro = this.valorFiltroTextBox.Text.ToUpper().Trim();
            }
            if (this.filtrosComboBox.SelectedIndex == 3)
            {
                myTipo      = TipoFiltro.NumeroPoliza;
                valorFiltro = this.valorFiltroTextBox.Text.ToUpper().Trim();
            }
            var myCommand = CmdCargarGrillaContratos.crear(this, this.listadoDataGridView, myTipo, valorFiltro);

            myCommand.Ejecutar();
            this.textoMetroLabel.Text = myCommand.TextoResultado.ToString();
            this.AsignarNombresDeColumnas();
            if (this.listadoDataGridView.Rows.Count > 0)
            {
                this.listadoDataGridView.Rows[0].Selected = true;
                this.listadoDataGridView.CurrentCell      = this.listadoDataGridView.Rows[0].Cells[0];
                this.MostrarDetalleDeContrato();
                this.listadoDataGridView.Focus();
            }
        }
Ejemplo n.º 17
0
 public static string IdReducidoFiltro(TipoFiltro fil)
 {
     if (fil == TipoFiltro.Diferente)
     {
         return("!=");
     }
     else if (fil == TipoFiltro.Exacto)
     {
         return("=");
     }
     else if (fil == TipoFiltro.Like)
     {
         return(":LIKE:");
     }
     else if (fil == TipoFiltro.Mayor)
     {
         return(">");
     }
     else if (fil == TipoFiltro.MayorIgual)
     {
         return(">=");
     }
     else if (fil == TipoFiltro.Menor)
     {
         return("<");
     }
     else if (fil == TipoFiltro.MenorIgual)
     {
         return("<=");
     }
     else if (fil == TipoFiltro.NotLike)
     {
         return(":NOTLIKE");
     }
     else
     {
         return("=");
     }
 }
Ejemplo n.º 18
0
        protected override void OnFilterAction()
        {
            KeyValuePair <string, string> value = ((KeyValuePair <string, string>)cboLista.SelectedItem);
            TipoFiltro filterType = TipoFiltro.Contiene;

            if (rbEmpieza.Checked)
            {
                filterType = TipoFiltro.Empieza;
            }
            else if (rbTermina.Checked)
            {
                filterType = TipoFiltro.Termina;
            }
            this.Source = mPersonaService.ObtenerTodo().Where(c => c.EstaActivo == true).ToList();
            var list = (List <Persona>) this.Source;

            GenericEntityAction <Persona> .Filter(ref list, value.Key, txtBuscar.Text, filterType);

            this.Source           = list;
            dgvListado.DataSource = null;
            dgvListado.DataSource = this.Source;
        }
Ejemplo n.º 19
0
        // Metodo para cargar los clientes.
        private void CargarClientes()
        {
            TipoFiltro myTipo      = TipoFiltro.Todo;
            string     valorFiltro = string.Empty;

            if (this.filtrosComboBox.SelectedIndex == 0)
            {
                myTipo = TipoFiltro.Todo;
            }
            if (this.filtrosComboBox.SelectedIndex == 1)
            {
                if (!this.ValidaRut())
                {
                    return;
                }
                myTipo      = TipoFiltro.Rut;
                valorFiltro = this.valorFiltroTextBox.Text;
            }
            if (this.filtrosComboBox.SelectedIndex == 2)
            {
                myTipo      = TipoFiltro.EstadoCivil;
                valorFiltro = this.valorFiltroComboBox.SelectedValue.ToString();
            }
            if (this.filtrosComboBox.SelectedIndex == 3)
            {
                myTipo      = TipoFiltro.Sexo;
                valorFiltro = this.valorFiltroComboBox.SelectedValue.ToString();
            }
            var myCommand = CmdCargarGrillaClientes.Crear(this, this.listadoDataGridView, myTipo, valorFiltro);

            myCommand.Ejecutar();
            this.textoMetroLabel.Text = myCommand.TextoResultado.ToString();
            if (this.listadoDataGridView.Rows.Count > 0)
            {
                this.listadoDataGridView.Rows[0].Selected = true;
                this.listadoDataGridView.Focus();
            }
        }
Ejemplo n.º 20
0
 private static void AddItemInList(string filterValue, ref List <T> filteredCollection, T item,
                                   object propertyValue, TipoFiltro filtrType)
 {
     if (filtrType == TipoFiltro.Empieza)
     {
         if (propertyValue.ToString().ToUpper().StartsWith(filterValue.ToUpper()))
         {
             filteredCollection.Add(item);
         }
     }
     else if (filtrType == TipoFiltro.Termina)
     {
         if (propertyValue.ToString().ToUpper().EndsWith(filterValue.ToUpper()))
         {
             filteredCollection.Add(item);
         }
     }
     else
     if (propertyValue.ToString().ToUpper().Contains(filterValue.ToUpper()))
     {
         filteredCollection.Add(item);
     }
 }
Ejemplo n.º 21
0
        private void cmdAceptar_Click(object sender, EventArgs e)
        {
            string descripcionFiltro = null;
            string ejercicio         = cboEjercicio.EditValue.ToString();
            string mes = null;

            if (cboMes.EditValue != null)
            {
                mes = cboMes.EditValue.ToString();
            }

            DateTime fechaInicial = new DateTime();
            DateTime fechaFinal   = new DateTime();

            if (deFechaInicial.EditValue != null)
            {
                fechaInicial = (DateTime)deFechaInicial.EditValue;
            }

            if (deFechaFinal.EditValue != null)
            {
                fechaFinal = (DateTime)deFechaFinal.EditValue;
            }

            string fechaInicialConsulta = null;
            string fechaFinalConsulta   = null;

            TipoFiltro tipoFiltroSel = (TipoFiltro)cboTipoFiltro.EditValue;

            switch (tipoFiltroSel)
            {
            case TipoFiltro.Todo:     //todos
                descripcionFiltro    = string.Format("TODO DEL EJERCICIO {0}", ejercicio);
                fechaInicialConsulta = string.Format("{0}-01-01", ejercicio);
                DateTime mesFinalEjercicio = new DateTime(Convert.ToInt32(ejercicio), 12, 1);
                fechaFinalConsulta = mesFinalEjercicio.AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd");
                break;

            case TipoFiltro.Mes:     //Mes
                descripcionFiltro    = string.Format("EJERCICIO {0} MES {1}", ejercicio, mes);
                fechaInicialConsulta = string.Format("{0}-{1}-01", ejercicio, mes);
                DateTime fechaMesConsulta = new DateTime(Convert.ToInt32(ejercicio), Convert.ToInt32(mes), 1);
                fechaFinalConsulta = fechaMesConsulta.AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd");
                break;

            case TipoFiltro.Rango:     //Rango de fecha
                if (fechaInicial == fechaFinal)
                {
                    descripcionFiltro = fechaInicial != SessionApp.DateServer
                            ? string.Format("DESDE {0} HASTA {1}", fechaInicial.ToString("dd/MM/yyyy"), fechaFinal.ToString("dd/MM/yyyy"))
                            : string.Format("HOY {0}", fechaInicial.ToString("dd/MM/yyyy"));
                }
                else
                {
                    descripcionFiltro = string.Format("DESDE {0} HASTA {1}", fechaInicial.ToString("dd/MM/yyyy"), fechaFinal.ToString("dd/MM/yyyy"));
                }

                fechaInicialConsulta = fechaInicial.ToString("yyyy-MM-dd");
                fechaFinalConsulta   = fechaFinal.ToString("yyyy-MM-dd");

                break;
            }

            //XtraMessageBox.Show(string.Format("{0} {1} {2}", descripcionFiltro, fechaInicialConsulta, fechaFinalConsulta));

            FiltroConsulta filtroConsultaSel = new FiltroConsulta();

            filtroConsultaSel.Tipo              = (TipoFiltro)cboTipoFiltro.EditValue;
            filtroConsultaSel.Ejercicio         = Convert.ToInt32(ejercicio);
            filtroConsultaSel.Mes               = mes;
            filtroConsultaSel.FechaInicial      = Convert.ToDateTime(fechaInicialConsulta);
            filtroConsultaSel.FechaFinal        = Convert.ToDateTime(fechaFinalConsulta);
            filtroConsultaSel.DescripcionFiltro = descripcionFiltro;

            FiltroConsulta = filtroConsultaSel;

            DialogResult = DialogResult.OK;
        }
Ejemplo n.º 22
0
 // Metodo para crear objeto.
 public static CmdCargarGrillaContratos crear(DataGridView myGrid, TipoFiltro myFiltro, string textoFiltro)
 {
     return(new CmdCargarGrillaContratos(myGrid, myFiltro, textoFiltro));
 }
Ejemplo n.º 23
0
 // Constructor.
 private CmdCargarGrillaContratos(DataGridView myGrid, TipoFiltro myFiltro, string textoFiltro)
     : base(myGrid, myFiltro, textoFiltro)
 {
 }
 // Constructores.
 protected CmdCargarDataGrid(DataGridView myGrid, TipoFiltro myFiltro, string textoFiltro)
 {
     this.myGrid      = myGrid;
     this.myFiltro    = myFiltro;
     this.textoFiltro = textoFiltro;
 }
 // Constructor.
 private CmdCargarGrillaClientes(Form myForm, DataGridView myGrid, TipoFiltro myFiltro, string textoFiltro)
     : base(myForm, myGrid, myFiltro, textoFiltro)
 {
 }
 // Metodo para crear objeto.
 public static CmdCargarGrillaClientes Crear(Form myForm, DataGridView myGrid, TipoFiltro myFiltro, string textoFiltro)
 {
     return(new CmdCargarGrillaClientes(myForm, myGrid, myFiltro, textoFiltro));
 }
Ejemplo n.º 27
0
        public void SetSelezioneItemRiparto(TipoFiltro tipo, RipartizioneSpeseDTO ripart, BusinessInstanceSelectedDTO item, MovimentoContabileDTO movimento, Dictionary<DettaglioSpesaDTO, RipartizioneSpeseDTO> ripartizione)
        {
            try
            {
                if (movimento != null && ripart != null)
                {
                    var key = GetKey(movimento);

                    // Se key è null o vuota vuol dire che il metdo è stato richiamato nell'evento cell update di una riga nuova: non deve essere fatto nulla
                    if (!string.IsNullOrEmpty(key))
                    {
                        if (item != null)
                            item.Stato = "U";

                        // Imposto come selezionati tutti gli altri filtri
                        switch (tipo)
                        {
                            case TipoFiltro.Scala:
                                if(ripart.Lotti != null && ripart.Lotti.ContainsKey(key))
                                    resetItemFiltro(ripart.Lotti[key]);
                                if (ripart.Stabili != null && ripart.Stabili.ContainsKey(key))
                                    resetItemFiltro(ripart.Stabili[key]);
                                break;
                            case TipoFiltro.Stabile:
                                if (ripart.Lotti != null && ripart.Lotti.ContainsKey(key))
                                    resetItemFiltro(ripart.Lotti[key]);
                                if (ripart.Gruppi != null && ripart.Gruppi.ContainsKey(key))
                                    resetItemFiltro(ripart.Gruppi[key]);
                                break;
                            case TipoFiltro.Lotto:
                                if (ripart.Stabili != null && ripart.Stabili.ContainsKey(key))
                                    resetItemFiltro(ripart.Stabili[key]);
                                if (ripart.Gruppi != null && ripart.Gruppi.ContainsKey(key))
                                    resetItemFiltro(ripart.Gruppi[key]);
                                break;
                        }

                        // Se multispesa tutti i filtri devono corrispondere
                        try
                        {
                            if (_isMultiSpesa && ripartizione != null)
                            {
                                foreach (var kvp in ripartizione)
                                {
                                    try
                                    {
                                        kvp.Value.Gruppi = ripart.Gruppi;
                                        kvp.Value.Lotti = ripart.Lotti;
                                        kvp.Value.Stabili = ripart.Stabili;
                                        kvp.Value.UnitaImmobiliari = ripart.UnitaImmobiliari;
                                    }
                                    catch (Exception ex)
                                    {
                                        var log = LogManager.GetLogger("Sfera");
                                        log.Error("Errore inaspettato nella  - MULTISPESA SINGOLO - " + Utility.GetMethodDescription() + " - tipo:" + tipo + " - azienda:" + Login.Instance.CurrentLogin().Azienda, ex);
                                        throw;
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            var log = LogManager.GetLogger("Sfera");
                            log.Error("Errore inaspettato nella  - MULTISPESA - " + Utility.GetMethodDescription() + " - tipo:" + tipo + " - azienda:" + Login.Instance.CurrentLogin().Azienda, ex);
                            throw;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var log = LogManager.GetLogger("Sfera");
                log.Error("Errore inaspettato nella funzione - " + Utility.GetMethodDescription() + " - tipo:" + tipo + " - azienda:" + Login.Instance.CurrentLogin().Azienda, ex);
            }
        }
Ejemplo n.º 28
0
        public static void Filter(ref List <T> collection, string property, string filterValue, TipoFiltro filtrType)
        {
            if (!string.IsNullOrEmpty(property) && collection != null && collection.Count > 0 &&
                !string.IsNullOrEmpty(filterValue))
            {
                var filteredCollection = new List <T>();
                foreach (var item in collection)
                {
                    // To check multiple properties use,
                    // item.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)

                    var propertyInfo = item.GetType()
                                       .GetProperty(property, BindingFlags.Public | BindingFlags.Instance);
                    if (propertyInfo == null)
                    {
                        throw new NotSupportedException("property given does not exists");
                    }

                    var propertyValue = propertyInfo.GetValue(item, null);
                    AddItemInList(filterValue, ref filteredCollection, item, propertyValue, filtrType);
                }
                collection = filteredCollection;
            }
        }