Exemple #1
0
        public IEnumerable <QuadroSolicitacaoViewModel> Quadro(int idUsuario, Usuario usuario, int codParametro)
        {
            var usuarioCliente = new UsuarioEF();

            var sb = new StringBuilder();

            sb.AppendLine(" SELECT");
            sb.AppendLine(" 	Sol_Id as Id,");
            sb.AppendLine(" 	Sol_Titulo as Titulo,");
            sb.AppendLine(" 	Sol_UsuarioAtendeAtual as IdUsuarioAtendeAtual,");
            sb.AppendLine(" 	Cli_Nome as ClienteNome,");
            sb.AppendLine(" 	Usu_Nome as UsuarioNome,");
            sb.AppendLine(" 	Sol_Status as IdStatus");
            sb.AppendLine(" FROM Solicitacao");
            sb.AppendLine(" 	INNER JOIN Cliente ON Sol_Cliente = Cli_Id");
            sb.AppendLine(" 	INNER JOIN Status ON Sol_Status = Sta_Id");
            sb.AppendLine(" 	INNER JOIN Parametros ON Sta_Codigo = COALESCE(Par_Valor, 0)");
            sb.AppendLine("   LEFT JOIN Usuario ON Sol_UsuarioAtendeAtual = Usu_Id");

            sb.AppendLine(" WHERE Par_Codigo = " + codParametro);
            sb.AppendLine(" AND Par_Programa = 3");
            sb.AppendLine(usuarioCliente.PermissaoUsuario(idUsuario));
            //sb.AppendLine(usuarioCliente.UsuarioCliente(idUsuario));
            sb.AppendLine(" ORDER BY Sol_Data");

            var lista = _repositorioDapperQuadro.GetAll(sb.ToString());

            //var lista = _rep.context.Database.SqlQuery<QuadroSolicitacao>(sb.ToString());

            return(lista);
        }
Exemple #2
0
        public IEnumerable <AgendamentoQuadroViewModel> Quadros(string dataInicial, string dataFinal, int idUsuario, int idRevenda)
        {
            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 ClienteNome,");
            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 Usuario ON Age_Usuario = Usu_Id");
            sb.AppendLine(" INNER JOIN Status ON Age_Status = Sta_Id");
            sb.AppendLine(" WHERE Age_Data >=" + Funcoes.DataIngles(dataInicial));
            sb.AppendLine(" AND Age_Data <=" + Funcoes.DataIngles(dataFinal));

            if (idRevenda > 0)
            {
                sb.AppendLine(" AND Cli_Revenda = " + idRevenda);
            }

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

            sb.AppendLine(" ORDER BY Age_Data");

            var lista = _repositorioQuadro.GetAll(sb.ToString());

            return(lista);
        }
Exemple #3
0
        public IEnumerable <ChamadoConsultaViewModel> Filtrar(ChamadoFiltroViewModel filtro, string campo, string texto, int usuarioId, bool contem, EnumChamado tipo)
        {
            var    usuarioCliente = new UsuarioEF();
            var    sb             = new StringBuilder();
            string sTexto         = "";

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

            sb.AppendLine("  SELECT");
            sb.AppendLine(" Cha_Id as Id,");
            sb.AppendLine(" '' as Descricao,");
            sb.AppendLine(" Cha_DataAbertura as DataAbertura,");
            sb.AppendLine(" Cha_HoraAbertura as HoraAbertura,");
            sb.AppendLine(" Sta_Nome as NomeStatus,");
            sb.AppendLine(" Cha_Status as IdStatus,");
            sb.AppendLine(" Tip_Nome as NomeTipo,");
            sb.AppendLine(" Cli_Nome as RazaoSocial,");
            sb.AppendLine(" Cli_Fantasia as Fantasia,");
            sb.AppendLine(" CASE Cha_Nivel");
            sb.AppendLine("   WHEN 1 THEN '1-Baixo'");
            sb.AppendLine("   WHEN 2 THEN '2-Normal'");
            sb.AppendLine("   WHEN 3 THEN '3-Alto'");
            sb.AppendLine("   WHEN 4 THEN '4-Crítico'");
            sb.AppendLine(" END AS Nivel,");
            sb.AppendLine(" Usu_Nome as NomeUsuario");
            sb.AppendLine(" FROM Chamado");
            sb.AppendLine("	INNER JOIN Status  ON Cha_Status = Sta_Id");
            sb.AppendLine("	INNER JOIN Tipo    ON Cha_Tipo = Tip_Id");
            sb.AppendLine(" INNER JOIN Cliente ON Cha_Cliente = Cli_Id");
            sb.AppendLine("	INNER JOIN Usuario ON Cha_UsuarioAbertura = Usu_Id");
            sb.AppendLine(" LEFT JOIN Revenda ON Cli_Revenda = Rev_Id");

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

            if (filtro.Id > 0)
            {
                sb.AppendLine(" AND Cha_Id = " + filtro.Id);
            }

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

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

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

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

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

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

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

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

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

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

            if (filtro.ClienteFiltro.UsuarioId > 0)
            {
                sb.AppendLine(" AND Cli_Usuario IN " + filtro.ClienteFiltro.UsuarioId);
            }
            sb.AppendLine(" ORDER BY " + campo);

            var lista = _repositorioConsulta.GetAll(sb.ToString());

            return(lista);
        }
Exemple #4
0
        private string RetornarSQLQuadro(int idUsuario, int idRevenda, int codigoParametro, string campoQuadro, EnumChamado tipo)
        {
            var    usuario   = new UsuarioEF();
            string sConsulta = usuario.PermissaoUsuario(idUsuario);

            var sb = new StringBuilder();

            sb.AppendLine(" SELECT");
            sb.Append(campoQuadro);
            sb.AppendLine("	Cha_Id as Id,");
            sb.AppendLine("	Cha_DataAbertura as DataAbertura,");
            sb.AppendLine("	Cha_HoraAbertura as HoraAbertura,");
            sb.AppendLine("	Cli_Nome as NomeCliente,");
            sb.AppendLine("	CASE cha_Nivel");
            sb.AppendLine("		WHEN 1 THEN '1-Baixo'");
            sb.AppendLine("		WHEN 2 THEN '2-Normal'");
            sb.AppendLine("		WHEN 3 THEN '3-Alto'");
            sb.AppendLine("		WHEN 4 THEN '4-Crítico'");
            sb.AppendLine("	END as NivelDescricao,");
            sb.AppendLine("  Cha_Nivel as Nivel,");
            sb.AppendLine("  Cha_UsuarioAtendeAtual as UsuarioAtendeAtualId,");
            sb.AppendLine("  Sta_Codigo as CodigoStatus,");
            sb.AppendLine("  Cli_Codigo as CodigoCliente,");
            sb.AppendLine("	Tip_Nome as NomeTipo,");
            sb.AppendLine("  UltimaHora = dbo.Func_Chamado_BuscarUltimaHoraOcorrencia (Cha_Id),");
            sb.AppendLine("	cha_HoraAtendeAtual as HoraAtendeAtual,");
            sb.AppendLine("  (");
            sb.AppendLine("	   SELECT MAX(CHAO.ChOco_Data) FROM dbo.Chamado_Ocorrencia AS CHAO");
            sb.AppendLine("		WHERE CHAO.ChOco_Chamado = dbo.Chamado.Cha_Id");
            sb.AppendLine(" 	) AS UltimaData,");
            sb.AppendLine("  Par_Codigo as CodigoParametro,");
            sb.AppendLine("	Usu_Nome as NomeUsuario");
            sb.AppendLine("FROM Chamado");
            sb.AppendLine("	INNER JOIN Cliente ON Cha_Cliente = Cli_Id");
            sb.AppendLine("	INNER JOIN Tipo ON Cha_Tipo = Tip_Id");
            sb.AppendLine("	INNER JOIN Status ON Cha_Status = Sta_Id");
            sb.AppendLine("	LEFT JOIN Parametros ON Sta_Codigo = COALESCE(Par_Valor, 0)");
            sb.AppendLine("  LEFT JOIN Usuario ON Cha_UsuarioAtendeAtual = Usu_Id");
            sb.AppendLine("WHERE par_Codigo = " + codigoParametro);
            sb.AppendLine(sConsulta);
            //sb.AppendLine("AND EXISTS(");
            //sb.AppendLine("	SELECT 1 FROM Usuario WHERE ((Cli_Revenda = Usu_Revenda) OR (Usu_Revenda IS NULL))");
            //sb.AppendLine("	AND Usu_Id = " + idUsuario + ")");
            //sb.AppendLine("AND EXISTS(");
            //sb.AppendLine("	SELECT 1 FROM Usuario WHERE ((Cli_Id = Usu_Cliente) OR (Usu_Cliente IS NULL))");
            //sb.AppendLine("	AND Usu_Id = " + idUsuario + ")");

            if (idRevenda > 0)
            {
                sb.AppendLine("AND (Cli_Revenda = " + idUsuario + ")");
            }

            sb.AppendLine(" --=============================================================================");

            if (tipo == EnumChamado.Chamado)
            {
                if (codigoParametro < 8)
                {
                    sb.AppendLine(" UNION ");
                }
            }
            else
            {
                if (codigoParametro < 30)
                {
                    sb.AppendLine(" UNION ");
                }
            }
            return(sb.ToString());
        }
Exemple #5
0
        private string FiltrarDados(int idUsuario, SolicitacaoFiltroViewModel filtro)
        {
            var usuarioCliente = new UsuarioEF();
            var sb             = new StringBuilder();

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

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

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

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

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

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

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

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

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

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

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

            //if (filtro.Nivel < 5)
            //    sb.AppendLine(" AND Sol_Nivel = " + filtro.Nivel);

            //if (filtro.ClienteFiltro.UsuarioId != "")
            //    sb.AppendLine(" AND Cli_Usuario IN " + filtro.ClienteFiltro.UsuarioId);

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

            if (filtro.Id > 0)
            {
                sb.AppendLine(" AND Sol_Id = " + filtro.Id);
            }

            return(sb.ToString());
        }
Exemple #6
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 = _repositorioConsulta.GetAll(sb.ToString());

            return(lista);
        }
 public UsuarioServico()
 {
     _rep          = new UsuarioEF();
     _tipoPrograma = EnProgramas.Usuario;
 }