Esempio n. 1
0
        Form_Redirect RedirectToForm(string _name)
        {
            ViewBag.Fiscal = Session["hashfiscalmov"] == null ? "N" : Session["hashfiscalmov"].ToString();
            Form_Redirect _fr = new Form_Redirect();

            Session["hashform"] = "";
            switch (_name)
            {
            case "mobreq":
                _fr.Controller = "MobReq"; _fr.Action = "Mobreq_menu";
                break;

            case "itbi":
                _fr.Controller = "Itbi"; _fr.Action = "Itbi_menu";
                break;

            case "parc":
                _fr.Controller = "Parcelamento"; _fr.Action = "Parc_index";
                break;

            case "2":
                _fr.Controller = "Imovel"; _fr.Action = "Carne_Iptu";
                break;

            case "3":
                _fr.Controller = "Imovel"; _fr.Action = "Carne_Cip";
                break;

            case "5":
                _fr.Controller = "Imovel"; _fr.Action = "Certidao_Endereco";
                break;

            case "6":
                _fr.Controller = "Imovel"; _fr.Action = "Certidao_Valor_Venal";
                break;

            case "7":
                _fr.Controller = "Imovel"; _fr.Action = "Certidao_Isencao";
                break;

            case "10":
                _fr.Controller = "Tributario"; _fr.Action = "Dama";
                break;

            case "11":
                _fr.Controller = "Empresa"; _fr.Action = "Carne_tl";
                break;

            case "12":
                _fr.Controller = "Empresa"; _fr.Action = "Carne_vs";
                break;

            case "13":
                _fr.Controller = "Empresa"; _fr.Action = "Details";
                break;

            case "14":
                _fr.Controller = "Empresa"; _fr.Action = "Alvara_Funcionamento";
                break;

            case "15":
                _fr.Controller = "Empresa"; _fr.Action = "Certidao_Inscricao";
                break;

            case "16":
                _fr.Controller = "Itbi"; _fr.Action = "Itbi_isencao";
                break;

            case "17":
                _fr.Controller = "Empresa"; _fr.Action = "Certidao_Pagamento";
                break;

            case "18":
                _fr.Controller = "Tributario"; _fr.Action = "Certidao_Debito_Codigo";
                break;

            case "19":
                _fr.Controller = "Tributario"; _fr.Action = "Certidao_Debito_Doc";
                break;

            case "20":
                _fr.Controller = "Tributario"; _fr.Action = "Comprovante_Pagamento";
                break;

            case "21":
                _fr.Controller = "Tributario"; _fr.Action = "Detalhe_Boleto";
                break;

            case "22":
                _fr.Controller = "Protocolo"; _fr.Action = "Consulta_Processo";
                break;

            case "23":
                _fr.Controller = "Tributario"; _fr.Action = "SegundaVia_Parcelamento";
                break;

            default:
                _fr.Controller = "Home"; _fr.Action = "SysMenu";
                break;
            }
            return(_fr);
        }
Esempio n. 2
0
        public ActionResult Login(LoginViewModel model)
        {
            string         sLogin = model.Usuario.Trim(), sNewPwd = model.Senha, sOldPwd, sOldPwd2, sName;
            LoginViewModel loginViewModel = new LoginViewModel();

            Sistema_bll     sistemaRepository = new Sistema_bll(_connection);
            TAcessoFunction tacesso_Class     = new TAcessoFunction();

            bool bFuncionario = model.Usuario.LastIndexOf('@') > 1 ? false : true;

            Session["hashfunc"] = bFuncionario ? "S" : "N";

            var cookieF = new HttpCookie("2fN*", Functions.Encrypt(bFuncionario ? "S" : "N"));

            cookieF.Expires = DateTime.Now.AddHours(1);
            System.Web.HttpContext.Current.Response.Cookies.Add(cookieF);


            Tributario_bll tributarioRepository = new Tributario_bll(_connection);
            Form_Redirect  fr = new Form_Redirect();

            if (bFuncionario)
            {
                sOldPwd = sistemaRepository.Retorna_User_Password(sLogin);
                int UserId = sistemaRepository.Retorna_User_LoginId(sLogin);
                if (sOldPwd == null)
                {
                    Session.Remove("hashid");
                    ViewBag.Result = "Usuário/Senha inválido!";
                    return(View(loginViewModel));
                }
                else
                {
                    sOldPwd2 = tacesso_Class.DecryptGTI(sOldPwd);
                    if (sOldPwd2 != sNewPwd)
                    {
                        ViewBag.Result = "Usuário/Senha inválido!";
                        Session.Remove("hashid");
                        return(View(loginViewModel));
                    }
                    else
                    {
                        ViewBag.Result    = "";
                        Session["hashid"] = UserId;
                    }
                }

                if (UserId == 0)
                {
                    ViewBag.Result = "Usuário/Senha inválido.";
                    return(View(loginViewModel));
                }

                usuarioStruct _user = sistemaRepository.Retorna_Usuario(UserId);
                if (_user.Ativo == 0)
                {
                    ViewBag.Result = "Usuário inativo.";
                    return(View(loginViewModel));
                }
                else
                {
                    Session["hashlname"]         = _user.Nome_login;
                    Session["hashfname"]         = _user.Nome_completo;
                    Session["hashfiscalitbi"]    = _user.Fiscal_Itbi ? "S" : "N";
                    Session["hashfiscalpostura"] = _user.Fiscal_postura ? "S" : "N";
                    Session["hashfiscalmov"]     = _user.Fiscal_mov ? "S" : "N";
                    Session["hashfiscal"]        = _user.Fiscal ? "S" : "N";
                    if (Session["hashid"] == null)
                    {
                        Session.Add("hashid", _user.Id);
                        Session.Add("hashfname", _user.Nome_completo);
                        Session.Add("hashlname", _user.Nome_login);
                        Session.Add("hashfiscalitbi", "N");
                        Session.Add("hashfiscalpostura", "N");
                        Session.Add("hashfiscalmov", "N");
                        Session.Add("hashfiscal", "N");
                        Session.Add("hashfunc", "N");
                    }
                    int  _userid = Convert.ToInt32(Session["hashid"]);
                    bool _func   = Session["hashfunc"].ToString() == "S" ? true : false;

                    //log
                    //LogWeb regWeb = new LogWeb() {UserId=_userid,Evento=1,Pref=true};
                    //sistemaRepository.Incluir_LogWeb(regWeb);
                    //***

                    List <int> ListaUsoPlataforma = tributarioRepository.Lista_Rodo_Uso_Plataforma_UserEmpresa(_userid, _func);
                    if (ListaUsoPlataforma.Count == 0)
                    {
                        ViewBag.UsoPlataforma = "N";
                    }
                    else
                    {
                        ViewBag.UsoPlataforma = "S";
                    }

                    // **Rememeber me
                    if (model.RememberMe)
                    {
                        var cookie = new HttpCookie("2lG*", Functions.Encrypt(model.Usuario));
                        cookie.Expires = DateTime.Now.AddDays(30);
                        System.Web.HttpContext.Current.Response.Cookies.Add(cookie);

                        cookie         = new HttpCookie("2pW*", Functions.Encrypt(model.Senha));
                        cookie.Expires = DateTime.Now.AddDays(30);
                        System.Web.HttpContext.Current.Response.Cookies.Add(cookie);
                    }
                    else
                    {
                        Response.Cookies["2lG*"].Expires = DateTime.Now.AddDays(-1);
                        Response.Cookies["2pW*"].Expires = DateTime.Now.AddDays(-1);
                    }
                    //******************
                    var cookie2 = new HttpCookie("2lG1H*", Functions.Encrypt(model.Usuario));
                    cookie2.Expires = DateTime.Now.AddHours(1);
                    System.Web.HttpContext.Current.Response.Cookies.Add(cookie2);
                    var cookie3 = new HttpCookie("2uC*", Functions.Encrypt(_userid.ToString()));
                    cookie3.Expires = DateTime.Now.AddHours(1);
                    System.Web.HttpContext.Current.Response.Cookies.Add(cookie3);

                    if (Session["hashform"] == null)
                    {
                        return(View("../Home/SysMenu"));
                    }
                    else
                    {
                        fr = RedirectToForm(Session["hashform"].ToString());
                    }
                }
            }
            else
            {
                Usuario_web user_web = sistemaRepository.Retorna_Usuario_Web(model.Usuario);
                if (user_web == null)
                {
                    ViewBag.Result = "Usuário/Senha inválido.";
                    return(View(loginViewModel));
                }
                else
                {
                    if (model.Senha != Functions.Decrypt(user_web.Senha))
                    {
                        ViewBag.Result = "Usuário/Senha inválido.";
                        return(View(loginViewModel));
                    }
                    else
                    {
                        if (!user_web.Ativo)
                        {
                            ViewBag.Result = "Esta conta encontra-se inativa.";
                            return(View(loginViewModel));
                        }
                        else
                        {
                            if (user_web.Bloqueado)
                            {
                                ViewBag.Result = "Esta conta encontra-se bloqueada.";
                                return(View(loginViewModel));
                            }
                            else
                            {
                                Session["hashid"]    = user_web.Id;
                                Session["hashlname"] = user_web.Email;
                                Session["hashfname"] = user_web.Nome;
                                Session.Add("hashfiscalitbi", "N");
                                Session.Add("hashfiscal", "N");
                                Session.Add("hashfunc", "N");
                                int  _userid = Convert.ToInt32(Session["hashid"]);
                                bool _func   = Session["hashfunc"].ToString() == "S" ? true : false;

                                //log
                                //LogWeb regWeb = new LogWeb() { UserId = _userid, Evento = 1, Pref = false };
                                //sistemaRepository.Incluir_LogWeb(regWeb);
                                //***
                                // **Rememeber me
                                if (model.RememberMe)
                                {
                                    var cookie = new HttpCookie("2lG*", Functions.Encrypt(model.Usuario));
                                    cookie.Expires = DateTime.Now.AddDays(30);
                                    System.Web.HttpContext.Current.Response.Cookies.Add(cookie);

                                    cookie         = new HttpCookie("2pW*", Functions.Encrypt(model.Senha));
                                    cookie.Expires = DateTime.Now.AddDays(30);
                                    System.Web.HttpContext.Current.Response.Cookies.Add(cookie);
                                }
                                else
                                {
                                    Response.Cookies["2lG*"].Expires = DateTime.Now.AddDays(-1);
                                    Response.Cookies["2pW*"].Expires = DateTime.Now.AddDays(-1);
                                }
                                //******************
                                var cookie2 = new HttpCookie("2lG1H*", Functions.Encrypt(model.Usuario));
                                cookie2.Expires = DateTime.Now.AddDays(1);
                                System.Web.HttpContext.Current.Response.Cookies.Add(cookie2);
                                var cookie3 = new HttpCookie("2uC*", Functions.Encrypt(user_web.Id.ToString()));
                                cookie3.Expires = DateTime.Now.AddHours(1);
                                System.Web.HttpContext.Current.Response.Cookies.Add(cookie3);



                                List <int> ListaUsoPlataforma = tributarioRepository.Lista_Rodo_Uso_Plataforma_UserEmpresa(_userid, _func);
                                if (ListaUsoPlataforma.Count == 0)
                                {
                                    ViewBag.UsoPlataforma = "N";
                                }
                                else
                                {
                                    ViewBag.UsoPlataforma = "S";
                                }
                                if (Session["hashform"] == null)
                                {
                                    return(View("../Home/SysMenu"));
                                }
                                else
                                {
                                    fr = RedirectToForm(Session["hashform"].ToString());
                                }
                            }
                        }
                    }
                }
            }
            return(RedirectToAction(fr.Action, fr.Controller));
        }