public Exception Incluir_Usuario_Web_Anexo(Usuario_web_anexo reg)
        {
            Sistema_Data obj = new Sistema_Data(_connection);
            Exception    ex  = obj.Incluir_Usuario_Web_Anexo(reg);

            return(ex);
        }
Exemple #2
0
        public JsonResult Inserir_Anexo(string Seq, string Id)
        {
            if (Request.Files.Count > 0)
            {
                Sistema_bll sistemaRepository = new Sistema_bll(_connection);
                foreach (string file in Request.Files)
                {
                    var _file             = Request.Files[file];
                    Usuario_web_anexo reg = new Usuario_web_anexo()
                    {
                        Userid  = Convert.ToInt32(Id),
                        Tipo    = Convert.ToInt16(Seq),
                        Arquivo = _file.FileName
                    };
                    Exception ex = sistemaRepository.Incluir_Usuario_Web_Anexo(reg);

                    //Salva cópia do Anexo
                    string fileName = "";
                    string _cod     = Convert.ToInt32(Id).ToString("00000");
                    string _path    = "~/Files/UserDoc/" + _cod;
                    Directory.CreateDirectory(Server.MapPath(_path));
                    fileName = _file.FileName;
                    var path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath(_path), fileName);
                    _file.SaveAs(path);
                    break;
                }
            }
            return(Json(new { success = true, responseText = "Arquivo anexado com sucesso." }, JsonRequestBehavior.AllowGet));
        }
Exemple #3
0
        public ActionResult User_doc()
        {
            LoginViewModel model = new LoginViewModel();

            if (Request.Cookies["2lG1H*"] == null)
            {
                return(RedirectToAction("Login"));
            }

            Sistema_bll sistemaRepository = new Sistema_bll(_connection);
            int         _userId           = Convert.ToInt32(Functions.Decrypt(Request.Cookies["2uC*"].Value));

            Usuario_web reg = sistemaRepository.Retorna_Usuario_Web(_userId);

            model.UserId       = _userId;
            model.Usuario      = reg.Nome;
            model.CpfCnpjLabel = Functions.FormatarCpfCnpj(reg.Cpf_Cnpj);
            bool _fisica = reg.Cpf_Cnpj.Length == 11 ? true : false;

            model.Lista_Usuario_Web_Anexo = sistemaRepository.Lista_Usuario_Web_Tipo_Anexo(_userId, _fisica);
            int _pos = 0;

            foreach (Usuario_Web_Anexo_Struct _anexo in model.Lista_Usuario_Web_Anexo)
            {
                Usuario_web_anexo _reg = sistemaRepository.Retorna_Web_Anexo(_userId, _anexo.Codigo);
                if (_reg != null)
                {
                    model.Lista_Usuario_Web_Anexo[_pos].Arquivo = Functions.TruncateTo(_reg.Arquivo, 32);
                }
                _pos++;
            }

            return(View(model));
        }
Exemple #4
0
        public FileResult Anexo_Download(string userid, string tipo)
        {
            int               _id               = Convert.ToInt32(userid);
            short             _tipo             = Convert.ToInt16(tipo);
            Sistema_bll       sistemaRepository = new Sistema_bll(_connection);
            Usuario_web_anexo _anexo            = sistemaRepository.Retorna_Usuario_Web_Anexo(_id, _tipo);
            string            _file             = _anexo.Arquivo;

            string fullName = Server.MapPath("~");

            fullName = Path.Combine(fullName, "Files");
            fullName = Path.Combine(fullName, "UserDoc");
            fullName = Path.Combine(fullName, _id.ToString("00000"));
            fullName = Path.Combine(fullName, _file);
            fullName = fullName.Replace("\\", "/");
            byte[] fileBytes = GetFile(fullName);
            return(File(
                       fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, _file));
        }
Exemple #5
0
        public JsonResult Carrega_User_Doc(string userId)
        {
            int         _user             = Convert.ToInt32(userId);
            Sistema_bll sistemaRepository = new Sistema_bll(_connection);
            Usuario_web _userWeb          = sistemaRepository.Retorna_Usuario_Web(_user);
            bool        _fisica           = _userWeb.Cpf_Cnpj.Length == 11 ? true : false;

            List <Usuario_Web_Anexo_Struct> Lista = sistemaRepository.Lista_Usuario_Web_Tipo_Anexo(_user, _fisica);
            int _pos = 0;

            foreach (Usuario_Web_Anexo_Struct _anexo in Lista)
            {
                Usuario_web_anexo _reg = sistemaRepository.Retorna_Web_Anexo(_user, _anexo.Codigo);
                if (_reg != null)
                {
                    Lista[_pos].Arquivo = Functions.TruncateTo(_reg.Arquivo, 32);
                }
                _pos++;
            }
            return(new JsonResult {
                Data = Lista, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }