public Dictionary<string, object> BuscarPorId(string Id, string Connection, string StringQuery, string dbType) { RepositoryHelper repositorio = new RepositoryHelper(dbType); Dictionary<string, object> entidade = new Dictionary<string, object>(); Dictionary<string, string> parameters = new Dictionary<string, string>(); parameters.Add("@id", Id); DataTableReader dataReader = repositorio.ExecutaQuery(Connection, StringQuery, CommandType.Text, parameters).CreateDataReader(); while (dataReader.Read()) { int fields = dataReader.FieldCount; for (int i = 0; i < fields; i++) { if (dataReader[i] == null) entidade.Add(dataReader.GetName(i).ToLower(), string.Empty); else { if (dataReader.GetName(i).ToLower().Contains("_cript")) entidade.Add(dataReader.GetName(i).ToLower().Replace("_cript", ""), Sennit.Cryptography.SennitCrypt.DeCrypt(dataReader[i].ToString(), "A!09#x*&aTe$")); else entidade.Add(dataReader.GetName(i).ToLower(), dataReader[i]); } } } return entidade; }
private static void BuscaRegistrosLista(string Connection, string StringQuery, Dictionary<string, string> parametros, PaginadoGenerico listaPaginado, RepositoryHelper repositorio, String TipoQuery) { System.Data.CommandType CommandType = CommandType.StoredProcedure; if (TipoQuery == "Text" || TipoQuery == "Select") { CommandType = CommandType.Text; DataTableReader dataReader = repositorio.ExecutaQuery(Connection, StringQuery, CommandType, parametros).CreateDataReader(); while (dataReader.Read()) { int fields = dataReader.FieldCount; Dictionary<string, object> parametrosLista = new Dictionary<string, object>(); for (int i = 0; i < fields; i++) { if (dataReader[i] == null) parametrosLista.Add(dataReader.GetName(i).ToLower(), string.Empty); else { if (dataReader.GetName(i).ToLower().Contains("_cript")) parametrosLista.Add(dataReader.GetName(i).ToLower().Replace("_cript", ""), Sennit.Cryptography.SennitCrypt.DeCrypt(dataReader[i].ToString(), "A!09#x*&aTe$")); else parametrosLista.Add(dataReader.GetName(i).ToLower(), dataReader[i]); } } listaPaginado._Lista.Add(parametrosLista); } } else { listaPaginado._Lista = repositorio.ExecutaQueryProcedure(Connection, StringQuery, CommandType, parametros); } }
private static void RetornaInformacoesLista(int page, int tamanhoDaPagina, string Connection, string QueryCount, Dictionary<string, string> parametros, PaginadoGenerico listaPaginado, RepositoryHelper repositorio) { DataTableReader dataReaderCount = repositorio.ExecutaQuery(Connection, QueryCount, System.Data.CommandType.Text, parametros).CreateDataReader(); listaPaginado.PaginaAtual = page; while (dataReaderCount.Read()) { listaPaginado.TotalDeRegistros = Convert.ToInt32(dataReaderCount[0].ToString()); if (tamanhoDaPagina != 0) listaPaginado.TotalDePaginas = (listaPaginado.TotalDeRegistros / tamanhoDaPagina); } listaPaginado.TamanhoDaPagina = page; listaPaginado.TotalDeRegistrosDaPagina = listaPaginado._Lista.Count; }