From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../RegistroAcaoRepository.cs | 183 --------------------- 1 file changed, 183 deletions(-) delete mode 100644 Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/RegistroAcaoRepository.cs (limited to 'Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/RegistroAcaoRepository.cs') diff --git a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/RegistroAcaoRepository.cs b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/RegistroAcaoRepository.cs deleted file mode 100644 index 158bcb9..0000000 --- a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/RegistroAcaoRepository.cs +++ /dev/null @@ -1,183 +0,0 @@ -using AutoMapper; -using Gestor.Infrastructure.Entities.Common; -using Gestor.Infrastructure.Mappers; -using Gestor.Infrastructure.Repository.Generic; -using Gestor.Infrastructure.Repository.Interface; -using Gestor.Infrastructure.UnitOfWork.Generic; -using Gestor.Model.Common; -using Gestor.Model.Domain.Common; -using Gestor.Model.Domain.Relatorios; -using NHibernate; -using NHibernate.Connection; -using NHibernate.Impl; -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.Common; -using System.Data.SqlClient; -using System.Linq; -using System.Linq.Expressions; -using System.Runtime.CompilerServices; - -namespace Gestor.Infrastructure.Repository.Logic -{ - public class RegistroAcaoRepository : GenericRepository, IRegistroAcaoRepository, IGenericRepository - { - private readonly GenericUnitOfWork _unitOfWork; - - public RegistroAcaoRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session) - { - this._unitOfWork = unitOfWork; - } - - public void Delete(long id) - { - RegistroAcaoDb registroAcaoDb = base.FindEntityById(id); - if (registroAcaoDb == null) - { - return; - } - base.Delete(registroAcaoDb); - } - - public List Find(Filtros filtros) - { - return this.Select(filtros); - } - - public List FindByEntityId(long id, TipoTela tela) - { - List list = ( - from x in base.All() - where x.EntidadeId == id && (int?)x.Tela == (int?)tela - select x).ToList(); - return ApplicationMapper.Mapper.Map, List>(list); - } - - public RegistroAcao FindById(long id) - { - RegistroAcaoDb registroAcaoDb = base.FindEntityById(id); - return ApplicationMapper.Mapper.Map(registroAcaoDb); - } - - public List FindOld(Filtros filtros, string connection) - { - return this.SelectOld(filtros, connection); - } - - public RegistroAcao SaveOrUpdate(RegistroAcao log) - { - RegistroAcaoDb registroAcaoDb = ApplicationMapper.Mapper.Map(log); - this.SaveOrUpdate(registroAcaoDb); - return ApplicationMapper.Mapper.Map(registroAcaoDb); - } - - private List Select(Filtros filtros) - { - List registroAcaos; - object connection; - DataTable dataTable = new DataTable(); - string str = (filtros.Usuarios == null || filtros.Usuarios.Count == 0 ? "" : string.Concat(" AND IdUsuario IN (", string.Join(",", - from v in filtros.Usuarios - select v), ")")); - string str1 = (filtros.Telas == null || filtros.Telas.Count == 0 ? "" : string.Concat(" AND Tela IN (", string.Join(",", - from v in filtros.Telas - select v), ")")); - string str2 = (filtros.Relatorios == null || filtros.Relatorios.Count == 0 ? "" : string.Concat(" AND Relatorio IN (", string.Join(",", - from v in filtros.Relatorios - select v), ")")); - string str3 = (filtros.Inicio == DateTime.MinValue ? "" : string.Format(" AND CAST(DataHora AS DATE) >= '{0:yyyy-MM-dd}'", filtros.Inicio)); - string str4 = (filtros.Fim == DateTime.MinValue ? "" : string.Format(" AND CAST(DataHora AS DATE) <= '{0:yyyy-MM-dd}'", filtros.Fim)); - SessionFactoryImpl sessionFactory = this._unitOfWork.Session.SessionFactory as SessionFactoryImpl; - if (sessionFactory != null) - { - connection = sessionFactory.ConnectionProvider.GetConnection(); - } - else - { - connection = null; - } - using (SqlConnection sqlConnection = connection as SqlConnection) - { - using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) - { - sqlCommand.CommandText = string.Concat(new string[] { "SELECT * FROM RegistroAcao WHERE 1=1 ", str3, str4, str, str1, str2 }); - using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter()) - { - sqlDataAdapter.SelectCommand = sqlCommand; - sqlDataAdapter.Fill(dataTable); - } - if (dataTable.Rows.Count != 0) - { - return CustomMap.MapLogAcao(dataTable); - } - else - { - registroAcaos = new List(); - } - } - } - return registroAcaos; - } - - private List SelectOld(Filtros filtros, string conn) - { - List registroAcaos; - object connection; - try - { - DataTable dataTable = new DataTable(); - string str = (filtros.Usuarios == null || filtros.Usuarios.Count == 0 ? "" : string.Concat(" AND IDUSUARIO IN (", string.Join(",", - from v in filtros.Usuarios - select v), ")")); - string str1 = (filtros.Inicio == DateTime.MinValue ? "" : string.Format(" AND CAST(DATA AS DATE) >= '{0:yyyy-MM-dd}'", filtros.Inicio)); - string str2 = (filtros.Fim == DateTime.MinValue ? "" : string.Format(" AND CAST(DATA AS DATE) <= '{0:yyyy-MM-dd}'", filtros.Fim)); - SessionFactoryImpl sessionFactory = this._unitOfWork.Session.SessionFactory as SessionFactoryImpl; - if (sessionFactory != null) - { - connection = sessionFactory.ConnectionProvider.GetConnection(); - } - else - { - connection = null; - } - using (SqlConnection sqlConnection = connection as SqlConnection) - { - using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) - { - sqlCommand.CommandText = "SELECT TOP 1 * FROM controlelog"; - SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); - sqlDataReader.Read(); - string str3 = sqlDataReader["bdname"].ToString(); - sqlDataReader["tabela"].ToString(); - sqlDataReader.Close(); - if (sqlConnection.Database != str3) - { - conn = conn.Replace(sqlConnection.Database, str3); - } - } - } - using (SqlConnection sqlConnection1 = new SqlConnection(conn)) - { - sqlConnection1.Open(); - using (SqlCommand sqlCommand1 = sqlConnection1.CreateCommand()) - { - sqlCommand1.CommandTimeout = 15000; - sqlCommand1.CommandText = string.Concat("SELECT IDACTION, ID, FORM, IDUSUARIO, DATA, ACAO, historico, maquina FROM actionlog WHERE 1=1 ", str1, str2, str); - using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter()) - { - sqlDataAdapter.SelectCommand = sqlCommand1; - sqlDataAdapter.Fill(dataTable); - } - } - } - registroAcaos = (dataTable.Rows.Count != 0 ? CustomMap.MapOldLogAcao(dataTable) : new List()); - } - catch (Exception exception) - { - registroAcaos = new List(); - } - return registroAcaos; - } - } -} \ No newline at end of file -- cgit v1.2.3