コード例 #1
0
        public IEnumerable <ChamadoOcorrencia> ListarProblemaSolucao(ChamadoFiltro filtro, string texto, int idUsuario, EnumChamado tipo)
        {
            var    usuario   = new UsuarioEF();
            string sConsulta = usuario.PermissaoUsuario(idUsuario);

            var sb = new StringBuilder();

            sb.AppendLine(" SELECT ");
            sb.AppendLine("   ChOco_Chamado,");
            sb.AppendLine("   ChOco_Data,");
            sb.AppendLine("   ChOco_HoraInicio,");
            sb.AppendLine("   ChOco_HoraFim,");
            sb.AppendLine("   ChOco_DescricaoSolucao,");
            sb.AppendLine("   ChOco_DescricaoTecnica,");
            sb.AppendLine("   Usu_Nome");
            sb.AppendLine(" FROM Chamado_Ocorrencia");
            sb.AppendLine("   INNER JOIN Chamado ON ChOco_Chamado = Cha_Id");
            sb.AppendLine("   INNER JOIN Cliente ON Cha_Cliente = Cli_Id");
            sb.AppendLine("   INNER JOIN Usuario ON ChOco_Usuario = Usu_Id	");
            sb.AppendLine(" WHERE ((ChOco_DescricaoTecnica LIKE " + texto + ") OR (ChOco_DescricaoSolucao LIKE " + texto + "))");
            sb.AppendLine(sConsulta);

            if (tipo == EnumChamado.Chamado)
            {
                sb.AppendLine(" AND cha_TipoMovimento = 1");
            }
            else
            {
                sb.AppendLine(" AND cha_TipoMovimento = 2");
            }

            if (filtro.IdCliente != "")
            {
                sb.AppendLine(" AND Cha_Cliente IN " + filtro.IdCliente);
            }

            sb.AppendLine(" ORDER BY ChOco_Data");

            var _repositorio = new RepositorioDapper <ChamadoOcorrencia>();

            return(_repositorio.GetAll(sb.ToString()));
        }
コード例 #2
0
 public ChamadoOcorrenciaEF()
 {
     _rep        = new Repositorio <ChamadoOcorrencia>();
     _repUsuario = new UsuarioEF();
 }
コード例 #3
0
        public IEnumerable <AgendamentoConsultaViewModel> Filtrar(AgendamentoFiltroViewModel filtro, string campo, string texto, int idUsuario, bool contem = true)
        {
            string sTexto = "";

            sTexto = "'" + texto + "%'";
            if (contem)
            {
                sTexto = "'%" + texto + "%'";
            }

            var sb             = new StringBuilder();
            var usuarioCliente = new UsuarioEF();

            sb.AppendLine(" SELECT");
            sb.AppendLine(" Age_Id as Id,");
            sb.AppendLine("	Age_Data as Data,");
            sb.AppendLine("	Age_Hora as Hora,");
            sb.AppendLine(" Age_Cliente as ClienteId,");
            sb.AppendLine(" Age_NomeCliente as NomeCliente,");
            sb.AppendLine(" Tip_Nome as TipoNome,");
            sb.AppendLine(" Usu_Nome as UsuarioNome,");
            sb.AppendLine(" Sta_Nome as StatusNome");
            sb.AppendLine(" FROM Agendamento");
            sb.AppendLine("     INNER JOIN Cliente ON Age_Cliente = Cli_Id");
            sb.AppendLine(" 	INNER JOIN Tipo ON Age_Tipo = Tip_Id");
            sb.AppendLine(" 	INNER JOIN Usuario ON Age_Usuario = Usu_Id");
            sb.AppendLine(" 	INNER JOIN Status ON Age_Status = Status.Sta_Id");

            if (!string.IsNullOrWhiteSpace(texto))
            {
                sb.AppendLine(" WHERE " + campo + " LIKE " + sTexto);
            }
            else
            {
                sb.AppendLine("WHERE Age_Id > 0");
            }

            sb.AppendLine(usuarioCliente.PermissaoUsuario(idUsuario));

            if ((!string.IsNullOrWhiteSpace(filtro.DataInicial)) && (filtro.DataInicial.Trim() != "/  /"))
            {
                sb.AppendLine(" AND Age_Data >=" + Funcoes.DataIngles(filtro.DataInicial));
            }

            if ((!string.IsNullOrWhiteSpace(filtro.DataFinal)) && (filtro.DataFinal.Trim() != "/  /"))
            {
                sb.AppendLine(" AND Age_Data <=" + Funcoes.DataIngles(filtro.DataFinal));
            }

            if (!string.IsNullOrWhiteSpace(filtro.IdCliente))
            {
                sb.AppendLine(" AND Age_Cliente IN (" + filtro.IdCliente + ")");
            }

            if (!string.IsNullOrWhiteSpace(filtro.IdTipo))
            {
                sb.AppendLine(" AND Age_Tipo IN (" + filtro.IdTipo + ")");
            }

            if (!string.IsNullOrWhiteSpace(filtro.IdStatus))
            {
                sb.AppendLine(" AND Age_Status IN (" + filtro.IdStatus + ")");
            }

            if (!string.IsNullOrWhiteSpace(filtro.IdUsuario))
            {
                sb.AppendLine(" AND Age_Usuario IN (" + filtro.IdUsuario + ")");
            }

            var lista = ctx.Database.SqlQuery <AgendamentoConsultaViewModel>(sb.ToString());

            return(lista);
        }