Exemplo n.º 1
0
        public ActionResult VerAnexoTarefa(Int32 id)
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            // Prepara view
            TAREFA_ANEXO item = baseApp.GetAnexoById(id);

            return(View(item));
        }
Exemplo n.º 2
0
        public FileResult DownloadTarefa(Int32 id)
        {
            TAREFA_ANEXO item         = baseApp.GetAnexoById(id);
            String       arquivo      = item.TAAN_AQ_ARQUIVO;
            Int32        pos          = arquivo.LastIndexOf("/") + 1;
            String       nomeDownload = arquivo.Substring(pos);
            String       contentType  = string.Empty;

            if (arquivo.Contains(".pdf"))
            {
                contentType = "application/pdf";
            }
            else if (arquivo.Contains(".jpg"))
            {
                contentType = "image/jpg";
            }
            else if (arquivo.Contains(".png"))
            {
                contentType = "image/png";
            }
            return(File(arquivo, contentType, nomeDownload));
        }
Exemplo n.º 3
0
        public TAREFA_ANEXO GetAnexoById(Int32 id)
        {
            TAREFA_ANEXO lista = _baseService.GetAnexoById(id);

            return(lista);
        }
Exemplo n.º 4
0
        public ActionResult UploadFileTarefa(HttpPostedFileBase file)
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            if (file == null)
            {
                ModelState.AddModelError("", GED_Resources.ResourceManager.GetString("M0019", CultureInfo.CurrentCulture));
                return(RedirectToAction("VoltarAnexoTarefa"));
            }

            Int32   idAss    = (Int32)Session["IdAssinante"];
            USUARIO usu      = (USUARIO)Session["UserCredentials"];
            TAREFA  item     = baseApp.GetById((Int32)Session["IdVolta"]);
            var     fileName = Path.GetFileName(file.FileName);

            if (fileName.Length > 100)
            {
                ModelState.AddModelError("", GED_Resources.ResourceManager.GetString("M0024", CultureInfo.CurrentCulture));
                return(RedirectToAction("VoltarAnexoTarefa"));
            }

            String caminho = "/Imagens/" + idAss.ToString() + "/Tarefas/" + item.TARE_CD_ID.ToString() + "/Anexos/";
            String path    = Path.Combine(Server.MapPath(caminho), fileName);

            file.SaveAs(path);

            //Recupera tipo de arquivo
            extensao = Path.GetExtension(fileName);
            String a = extensao;

            // Gravar registro
            TAREFA_ANEXO foto = new TAREFA_ANEXO();

            foto.TAAN_AQ_ARQUIVO = "~" + caminho + fileName;
            foto.TAAN_DT_ANEXO   = DateTime.Today;
            foto.TAAN_IN_ATIVO   = 1;
            Int32 tipo = 4;

            if (extensao.ToUpper() == ".JPG" || extensao.ToUpper() == ".GIF" || extensao.ToUpper() == ".PNG" || extensao.ToUpper() == ".JPEG")
            {
                tipo = 1;
            }
            if (extensao.ToUpper() == ".MP4" || extensao.ToUpper() == ".AVI" || extensao.ToUpper() == ".MPEG")
            {
                tipo = 2;
            }
            if (extensao.ToUpper() == ".PDF")
            {
                tipo = 3;
            }
            foto.TAAN_IN_TIPO   = tipo;
            foto.TAAN_NM_TITULO = fileName;
            foto.TARE_CD_ID     = item.TARE_CD_ID;

            item.TAREFA_ANEXO.Add(foto);
            objetoAntes = item;
            Int32 volta = baseApp.ValidateEdit(item, objetoAntes);

            return(RedirectToAction("VoltarAnexoTarefa"));
        }