public ActionResult Documento(int id = 0)
        {
            ActionResult      result    = null;
            DocumentoDownload documento = EventoDocumentiElencoRepository.Instance.RecuperaDocumentoDownload(id);

            if (documento != null)
            {
                string filepath = null;
                string ext      = documento.Estensione;
                string nomeFile = documento.PercorsoFile.Substring(documento.PercorsoFile.LastIndexOf("/") + 1);

                filepath = FileUtility.VADocumentoAiaEventi(documento.PercorsoFile);

                if (System.IO.File.Exists(filepath))
                {
                    result = File(filepath, "application/octet-stream", nomeFile);
                    if (!Request.Browser.Crawler)
                    {
                        new VAWebRequestDocumentoDownloadEvent("VA Download documento", this, id, VAWebEventTypeEnum.DownloadAltroDocumento).Raise();
                    }
                }
                else
                {
                    result = HttpNotFound();
                }
            }
            else
            {
                result = HttpNotFound();
            }

            return(result);
        }
        public IEnumerable <DocumentoDownload> RecuperaDocumentiDownloadPerProvvedimento(int provvedimentoID)
        {
            List <DocumentoDownload> documenti = new List <DocumentoDownload>();
            SqlServerExecuteObject   sseo      = null;
            SqlDataReader            dr        = null;

            string sSql = @"SELECT D.DocumentoID, OP.OggettoID, D.PercorsoFile, TF.Estensione, OP.OggettoProceduraID, T0.MacroTipoOggettoID
                            FROM dbo.TBL_Documenti AS D 
                                INNER JOIN dbo.TBL_OggettiProcedure AS OP ON OP.OggettoProceduraID = D.OggettoProceduraID 
                                INNER JOIN dbo.TBL_Oggetti AS O ON O.OggettoID = OP.OggettoID 
                                INNER JOIN dbo.TBL_TipiOggetto AS T0 ON T0.TipoOggettoID = O.TipoOggettoID
                                INNER JOIN dbo.TBL_TipiFile AS TF ON TF.TipoFileID = D.TipoFileID 
                                INNER JOIN dbo.STG_ProvvedimentiDocumenti AS SPD ON SPD.DocumentoID = D.DocumentoID
                            WHERE D.LivelloVisibilita = 1 AND SPD.ProvvedimentoID = @ProvvedimentoID;";

            sseo             = new SqlServerExecuteObject();
            sseo.CommandText = sSql;
            sseo.CommandType = CommandType.Text;
            sseo.SqlParameters.AddWithValue("@ProvvedimentoID", provvedimentoID);

            dr = SqlProvider.ExecuteReaderObject(sseo);

            // Documento
            while (dr.Read())
            {
                DocumentoDownload documento = new DocumentoDownload();

                documento.ID                 = dr.GetInt32(0);
                documento.OggettoID          = dr.GetInt32(1);
                documento.PercorsoFile       = dr.GetString(2);
                documento.Estensione         = dr.GetString(3);
                documento.OggettoProceduraID = dr.GetInt32(4);
                documento.MacroTipoOggettoID = dr.GetInt32(5);

                documenti.Add(documento);
            }


            if (dr != null)
            {
                dr.Close();
                dr.Dispose();
            }

            return(documenti);
        }
Exemple #3
0
        public ActionResult Documento(int id = 0)
        {
            ActionResult      result    = null;
            DocumentoDownload documento = DocumentoRepository.Instance.RecuperaDocumentoDownload(id);

            if (documento != null)
            {
                string filepath    = null;
                string contenttype = null;
                string ext         = documento.Estensione;
                string nomeFile    = documento.PercorsoFile.Substring(documento.PercorsoFile.LastIndexOf("/") + 1);

                contenttype = ContentTypeByExtension(string.Format(".{0}", ext));
                if (documento.MacroTipoOggettoID == (int)MacroTipoOggettoEnum.Aia)
                {
                    filepath = FileUtility.VADocumentoAia(string.Format("I{0}_P{1}/{2}.{3}", documento.OggettoID, documento.OggettoProceduraID, documento.PercorsoFile, ext));
                }
                else
                {
                    filepath = FileUtility.VADocumentoViaVas(string.Format("ID_Prog_{0}/{1}.{2}", documento.OggettoID, documento.PercorsoFile, ext));
                }

                if (System.IO.File.Exists(filepath))
                {
                    result = File(filepath, contenttype, string.Format("{0}.{1}", nomeFile, ext));
                    if (!Request.Browser.Crawler)
                    {
                        new VAWebRequestDocumentoDownloadEvent("VA Download documento", this, id, VAWebEventTypeEnum.DownloadDocumentoOggetto).Raise();
                    }
                }
                else
                {
                    result = HttpNotFound();
                }
            }
            else
            {
                result = HttpNotFound();
            }

            return(result);
        }
Exemple #4
0
        public DocumentoDownload RecuperaDocumentoDownload(int id)
        {
            DocumentoDownload      documento = null;
            SqlServerExecuteObject sseo      = null;
            SqlDataReader          dr        = null;

            string sSql = @"SELECT D.DocumentoID, D.PercorsoFile 
                            FROM dbo.GEMMA_AIAtblDocumenti AS D 
                            WHERE D.LivelloVisibilita = 1 AND D.DocumentoID = @DocumentoID";

            sseo             = new SqlServerExecuteObject();
            sseo.CommandText = sSql;
            sseo.CommandType = CommandType.Text;
            sseo.SqlParameters.AddWithValue("@DocumentoID", id);

            dr = SqlProvider.ExecuteReaderObject(sseo);

            // Documento
            while (dr.Read())
            {
                documento = new DocumentoDownload();

                documento.ID = dr.GetInt32(0);
                //documento.OggettoID = dr.GetInt32(1);
                documento.PercorsoFile = dr.GetString(1);
                //documento.Estensione = getTipoFile(dr.GetString(3)).Estensione;
                //documento.OggettoProceduraID = dr.GetInt32(4);
                //documento.MacroTipoOggettoID = dr.GetInt32(5);
            }


            if (dr != null)
            {
                dr.Close();
                dr.Dispose();
            }

            return(documento);
        }