Ejemplo n.º 1
0
        public static int Agregar(BE.EmpleadoBE pEmpleado)
        {
            ///Creo su padre y lo guardo antes.
            BE.UsuarioBE baseUser = new BE.UsuarioBE();

            baseUser.Document = pEmpleado.Document;
            baseUser.Password = pEmpleado.Password;
            baseUser.FecAlta  = DateTime.Now;
            baseUser.Tipo     = BE.UsuarioTipo.Emplado;
            baseUser.Estado   = BE.EstadoUsuario.Activo;

            UsuarioDAL.Agregar(baseUser);

            //Guardo el empleado.
            string sql  = "insert into empleado(usuario_id, nombre, apellido, email, fec_nac, activo) values(@userId, @name, @surname, @email, @fecNac,'true');";
            DAO    mDao = new DAO();

            return(mDao.ExecuteNonQueryWithParams(sql, new List <SqlParameter> {
                mDao.CreateParameter("userId", SqlDbType.Int, 1),
                mDao.CreateParameter("name", SqlDbType.VarChar, pEmpleado.Nombre),
                mDao.CreateParameter("surname", SqlDbType.VarChar, pEmpleado.Apellido),
                mDao.CreateParameter("email", SqlDbType.VarChar, pEmpleado.Email),
                mDao.CreateParameter("fecNac", SqlDbType.DateTime, pEmpleado.FecNac)
            }));
        }
        public static List <BitacoraBE> Buscar(DateTime fechaInicio, DateTime fechaFin, int usuarioId, string texto)
        {
            string query = "SELECT fecha_hora, usuario_id, detalle FROM bitacora WHERE fecha_hora BETWEEN @fechaInicio AND @fechaFin";
            List <SqlParameter> paramList = new List <SqlParameter> {
                new SqlParameter("@fechaInicio", fechaInicio),
                new SqlParameter("@fechaFin", fechaFin)
            };

            if (usuarioId > 0)
            {
                query += " AND usuario_id = @usuarioId";
                paramList.Add(new SqlParameter("@usuarioId", usuarioId));
            }
            if (!string.IsNullOrEmpty(texto))
            {
                query += " AND detalle LIKE @detalle";
                paramList.Add(new SqlParameter("@detalle", "%" + texto + "%"));
            }
            DataTable         table     = SqlHelper.Obtener(query, paramList.ToArray(), SqlHelper.Bd.Bitacora);
            List <BitacoraBE> bitacoras = new List <BitacoraBE>();

            foreach (DataRow row in table.Rows)
            {
                BitacoraBE bitacora = new BitacoraBE
                {
                    FechaHora = DateTime.Parse(row["fecha_hora"].ToString()),
                    Usuario   = UsuarioDAL.Obtener(int.Parse(row["usuario_id"].ToString())),
                    Detalle   = row["detalle"].ToString()
                };
                bitacoras.Add(bitacora);
            }
            return(bitacoras);
        }
Ejemplo n.º 3
0
        public ActionResult EfetuarLogin(string Login, string Senha)
        {
            //Resposta resposta = new Resposta();
            //resposta.Erro = false;
            //resposta.Mensagem = "Login inválido. Acesso Negado!";

            ResponseLogin resp = new ResponseLogin();
            //resp.Nome = "Ednilson Martins";
            //resp.Resposta = resposta;

            resp = new LoginDAL().EfetuarLogin(Login, Senha);
            if (resp.Resposta.Erro)
            {
                resp.Resposta.Mensagem = Resources.Portal.Login_Mensagem_Invalido;//"Login inválido. Acesso Negado!";
            }
            else
            {
                List<Funcionalidade> listaFuncionalidades = new UsuarioDAL().CarregarUsuarioFuncionalidade(resp.UsuarioId);
                if (listaFuncionalidades.Any(x => x.FuncionalidadeId == 1))
                {
                    var usuarioCookie = new HttpCookie("UsuarioId", resp.UsuarioId.ToString()) { HttpOnly = true };
                    Response.AppendCookie(usuarioCookie);
                    var usuarioNomeCookie = new HttpCookie("UsuarioNome", resp.Nome.ToString()) { HttpOnly = true };
                    Response.AppendCookie(usuarioNomeCookie);
                }
                else
                {
                    resp.Resposta.Erro = true;
                    resp.Resposta.Mensagem = Resources.Portal.Login_Mensagem_Invalido;
                }
            }

            return Json(resp, JsonRequestBehavior.DenyGet);
        }
Ejemplo n.º 4
0
        public ActionResult Index(LoginModel login)
        {
            ResponseLogin resp = new ResponseLogin();

            resp = new LoginDAL().EfetuarLogin(login.username, login.password);
            if (resp.Resposta.Erro)
            {
                login.Autenticado = false;
                login.Mensagem = "Login inválido. Acesso Negado!";
            }
            else
            {
                var usuarioCookie = new HttpCookie("CMS_UsuarioId", resp.UsuarioId.ToString()) { HttpOnly = true };
                Response.AppendCookie(usuarioCookie);
                var usuarioNomeCookie = new HttpCookie("CMS_UsuarioNome", resp.Nome.ToString()) { HttpOnly = true };
                Response.AppendCookie(usuarioNomeCookie);
                var permanecerConectadoCookie = new HttpCookie("CMS_PermanecerConectado", login.PermanecerConectado.ToString()) { HttpOnly = true };
                Response.AppendCookie(permanecerConectadoCookie);

                #region --> Verifica site Padrão

                List<Funcionalidade> listaFuncionalidades = new UsuarioDAL().CarregarUsuarioFuncionalidade(resp.UsuarioId);
                string SiteId = "0";
                string SiteNome = "";

                if (listaFuncionalidades.Any(x => x.FuncionalidadeId == 10))
                {
                    SiteId = "1";
                    SiteNome = "CCBC";
                } else if (listaFuncionalidades.Any(x => x.FuncionalidadeId == 20))
                {
                    SiteId = "2";
                    SiteNome = "CAM-CCBC";
                }
                else
                {
                    resp.Resposta.Erro = true;
                    login.Autenticado = false;
                    login.Mensagem = "Acesso restrito ao CMS!";
                }

                var siteId = new HttpCookie("CMS_SiteId", SiteId) { HttpOnly = true };
                Response.AppendCookie(siteId);

                var siteNome = new HttpCookie("CMS_SiteNome", SiteNome) { HttpOnly = true };
                Response.AppendCookie(siteNome);

                #endregion

                if (!resp.Resposta.Erro)
                {
                    return RedirectPermanent("~/");
                }
            }

            return View(login);
        }
Ejemplo n.º 5
0
        public ActionResult RecuperarSenha(string Email)
        {
            UsuarioResponse resp = new UsuarioResponse();

            resp = new UsuarioDAL().Carregar(Email);
            if (resp.Resposta.Erro)
            {
                //Retornar mensagem de erro.
            }
            else
            {
                if (resp.Usuario.UsuarioId != 0)
                {
                    //Enviar e-mail.
                }
                else
                {
                    resp.Resposta.Erro = true;
                    resp.Resposta.Mensagem = "Usuário não localizado, verifique o endereço de e-mail informado!";
                }
            }

            return Json(resp, JsonRequestBehavior.AllowGet); ;
        }
Ejemplo n.º 6
0
        public ActionResult GravarUsuario(string Usuario, string UsuarioOld, string ListaUsuarioGrupo)
        {
            var form = (JObject)JsonConvert.DeserializeObject(Usuario);

            UsuarioDTO _anterior = new UsuarioDTO();
            UsuarioDTO _novo = new UsuarioDTO();

            _novo.UsuarioId = (int)Util.GetValue<int>(form, "UsuarioId");
            _novo.Nome = (string)Util.GetValue<string>(form, "Nome");
            _novo.Email = (string)Util.GetValue<string>(form, "Email");
            _novo.Login = (string)Util.GetValue<string>(form, "Login");
            _novo.Senha = (string)Util.GetValue<string>(form, "Password");
            _novo.Ativo = Convert.ToBoolean((int?)Util.GetValue<int?>(form, "Ativo"));
            _novo.SiteId = GetCurrentSite();
            _novo.TedescoUsuario = (string)Util.GetValue<string>(form, "TedescoUsuario");
            _novo.TedescoEmail = (string)Util.GetValue<string>(form, "TedescoEmail");

            if (UsuarioOld != null && UsuarioOld != "null")
            {
                var formOld = (JObject)JsonConvert.DeserializeObject(UsuarioOld);

                _anterior.UsuarioId = (int)Util.GetValue<int>(formOld, "UsuarioId");
                _anterior.Nome = (string)Util.GetValue<string>(formOld, "Nome");
                _anterior.Email = (string)Util.GetValue<string>(formOld, "Email");
                _anterior.Login = (string)Util.GetValue<string>(formOld, "Login");
                _anterior.Ativo = Convert.ToBoolean((int?)Util.GetValue<int?>(formOld, "Ativo"));
                _anterior.TedescoUsuario = (string)Util.GetValue<string>(formOld, "TedescoUsuario");
                _anterior.TedescoEmail = (string)Util.GetValue<string>(formOld, "TedescoEmail");

            }

            List<Funcionalidade> funcs = new UsuarioDAL().ListarFuncionalidades(1);
            funcs.ForEach(delegate(Funcionalidade f)
            {
                ValidarFuncionalidade(form, f.FuncionalidadeId, ref _novo);
            });

            return Json(new UsuarioDAL().Gravar(_novo, _anterior, ListaUsuarioGrupo), JsonRequestBehavior.AllowGet);
        }