Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Expires = -1;
            DocsPaWR.FileDocumento theDoc = null;
            string PosLabelPdf            = null;

            DocsPaWR.labelPdf label = new DocsPAWA.DocsPaWR.labelPdf();
            bool   tipo             = false;
            string rotazione        = null;
            string orientamento     = null;
            string carattere        = string.Empty;
            string colore           = string.Empty;

            DocsPaWR.SchedaDocumento schedaCorrente = DocumentManager.getDocumentoSelezionato(Page);

            DocsPaVO.documento.FileRequest fr = new DocsPaVO.documento.FileRequest();

            if (this.Session["personalize"] != null)
            {
                PosLabelPdf = this.Session["personalize"].ToString();
            }
            if (Session["tipoLabel"] != null)
            {
                tipo = System.Convert.ToBoolean(Session["tipoLabel"].ToString());
            }
            if (Session["rotazione"] != null)
            {
                rotazione = Session["rotazione"].ToString();
            }
            if (Session["carattere"] != null)
            {
                carattere = Session["carattere"].ToString();
            }
            if (Session["colore"] != null)
            {
                colore = Session["colore"].ToString();
            }
            if (Session["orientamento"] != null)
            {
                orientamento = Session["orientamento"].ToString();
            }
            //carico i dati dentro l'oggetto Label
            label.position       = PosLabelPdf;
            label.tipoLabel      = tipo;
            label.label_rotation = rotazione;
            label.sel_font       = carattere;
            label.sel_color      = colore;
            label.orientamento   = orientamento;
            theDoc = FileManager.getInstance(Session.SessionID).getVoidFileConSegnatura(fr, schedaCorrente, label, this);

            //aggiungo in session le info relative alle label
            Session.Add("labelProperties", theDoc.LabelPdf);
            if (theDoc != null)
            {
                Response.ContentType = theDoc.contentType;
                Response.AddHeader("content-disposition", "inline;filename=" + theDoc.name);
                Response.AddHeader("content-length", theDoc.content.Length.ToString());
                Response.BinaryWrite(theDoc.content);
            }
        }
Example #2
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            Response.Expires = -1;
            DocsPaWR.FileDocumento theDoc = null;
            DocsPaWR.labelPdf      label  = new DocsPAWA.DocsPaWR.labelPdf();
            string id           = string.Empty;
            string plusEtic     = string.Empty;
            string PosLabelPdf  = null;
            bool   tipo         = false;
            bool   primaPag     = false;
            bool   ultimaPag    = false;
            string rotazione    = null;
            string carattere    = string.Empty;
            string colore       = string.Empty;
            string orientamento = null;
            //Mev Firma1 < diciarazione variabile
            string notimbro = string.Empty;
            //>
            string versioneStampabile = string.Empty;

            // Valore booleano per indicare se il documento va visualizzato
            // nel suo formato originale
            bool visInOrig = false;

            // Se il query string contiene visInOrig impostato a 1
            // ed il ruolo è abilitato alla visualizzazione del file in
            // originale
            if (!string.IsNullOrEmpty(Request.QueryString["visInOrig"]) &&
                Request.QueryString["visInOrig"].ToString().Equals("1") &&
                UserManager.ruoloIsAutorized(this, "DO_VIS_ORIG"))
            {
                visInOrig = true;
            }

            if (Session["docToSign"] == null)
            {
                id           = Request["id"];
                plusEtic     = Request["plusEtic"];
                PosLabelPdf  = Request["pos"];
                tipo         = System.Convert.ToBoolean(Request["tipo"]);
                rotazione    = Request["rotazione"];
                carattere    = Request["carattere"];
                colore       = Request["colore"];
                orientamento = Request["orientamento"];
                //MEV Firma1 < set su variabile notimbro
                notimbro = Request["notimbro"];
                //>
                versioneStampabile = Request["versioneStampabile"];
                //carico i dati dentro l'oggetto Label
                label.position       = PosLabelPdf;
                label.tipoLabel      = tipo;
                label.label_rotation = rotazione;
                label.orientamento   = orientamento;
                //Mev Firma1 <
                if (notimbro != null)
                {
                    label.notimbro = (notimbro.ToUpper() == "TRUE") ? true : false;
                }
                else
                {
                    label.notimbro = false;
                }
                //>
                label.sel_font  = carattere;
                label.sel_color = colore;
                primaPag        = System.Convert.ToBoolean(this.Session["printOnFirstPage"]);
                ultimaPag       = System.Convert.ToBoolean(this.Session["printOnLastPage"]);
                if (primaPag || ultimaPag)
                {
                    label.digitalSignInfo = new DocsPaWR.labelPdfDigitalSignInfo();
                    label.digitalSignInfo.printOnFirstPage = primaPag;
                    label.digitalSignInfo.printOnLastPage  = ultimaPag;
                }
                //Mev Firma1 <
                if (Session["printFormatSign"] != null)
                {
                    label.digitalSignInfo.printFormatSign = (DocsPaWR.TypePrintFormatSign)Session["printFormatSign"];
                }
                //>


                // Garantisce che nella selezione del comando “Visualizza dati con segnatura” siano sempre e
                // solo mostrati i dati identificativi del documento.
                // Non vengono mantenute in sessione eventuali selezioni operate nella popup di posizionamento dati.
                if (Session["SHOWDOCWITHSEGNATURE"] != null)
                {
                    label.digitalSignInfo = null;
                }
                //>

                if (!(id != null && !id.Equals("")))
                {
                    id = Session.SessionID;
                }

                DocsPaWR.FileRequest fileRequestVisualizzatore = this.Session["VisualizzatoreUnificato.SelectedFileRequest"] as DocsPaWR.FileRequest;

                DocsPaWR.SchedaDocumento schedaCorrente = DocumentManager.getDocumentoSelezionato(Page);

                if (plusEtic != null && plusEtic != "" && schedaCorrente != null && fileRequestVisualizzatore != null && !string.IsNullOrEmpty(schedaCorrente.docNumber) && !string.IsNullOrEmpty(fileRequestVisualizzatore.docNumber) && schedaCorrente.docNumber.Equals(fileRequestVisualizzatore.docNumber))
                {
                    if (fileRequestVisualizzatore == null)
                    {
                        theDoc = FileManager.getInstance(id).getFileConSegnatura(this, schedaCorrente, label, null);
                    }
                    else
                    {
                        theDoc = FileManager.getInstance(id).getFileConSegnatura(this, schedaCorrente, label, fileRequestVisualizzatore);
                        this.Session.Remove("VisualizzatoreUnificato.SelectedFileRequest");
                    }

                    //aggiungo in session le info relative alle label
                    Session.Add("labelProperties", theDoc.LabelPdf);
                }
                else
                {
                    bool showAsPdfFormat = false;

                    // Se visInOrig è false...
                    if (!visInOrig)
                    {
                        try
                        {
                            // Verifica se convertire il file visualizzato in pdf
                            string config = ConfigurationManager.AppSettings["SHOW_DOCUMENT_AS_PDF_FORMAT"];

                            if (config != null && config != string.Empty)
                            {
                                showAsPdfFormat = Convert.ToBoolean(config);
                            }
                        }
                        catch { }
                    }

                    if (fileRequestVisualizzatore == null)
                    {
                        theDoc = FileManager.getInstance(id).getFile(this, showAsPdfFormat);
                    }
                    else
                    {
                        if (fileRequestVisualizzatore.fileName.ToUpper().EndsWith(".EML"))
                        {
                            if (!string.IsNullOrEmpty(versioneStampabile) && versioneStampabile.ToUpper().Equals("FALSE"))
                            {
                                theDoc = FileManager.getInstance(id).getFileAsEML(this, fileRequestVisualizzatore);
                            }
                            else
                            {
                                theDoc = FileManager.getInstance(id).getFile(this, fileRequestVisualizzatore, showAsPdfFormat);
                            }
                        }
                        else
                        {
                            theDoc = FileManager.getInstance(id).getFile(this, fileRequestVisualizzatore, showAsPdfFormat);
                        }
                        this.Session.Remove("VisualizzatoreUnificato.SelectedFileRequest");
                    }
                }
            }
            else
            {
                theDoc = (DocsPAWA.DocsPaWR.FileDocumento)Session["docToSign"];
            }

            if (theDoc != null && (!string.IsNullOrEmpty(theDoc.name)))
            {
                bool downloadAsAttatchment;
                bool.TryParse(this.Request.QueryString["downloadAsAttatchment"], out downloadAsAttatchment);

                if (theDoc.estensioneFile == null && theDoc.fullName.Contains("."))
                {
                    string extension = theDoc.fullName.Substring(theDoc.fullName.LastIndexOf(".") + 1);
                    theDoc.estensioneFile = extension;
                    if (theDoc.estensioneFile.ToUpper().Equals("XML"))
                    {
                        //elaborazione per la fattura elettronica
                        byte[] xlstFatt = fatturazioneElettronicaInsertXlst(theDoc.content);
                        if (xlstFatt == null)
                        {
                            theDoc.contentType = "image/jpeg";
                        }
                        else
                        {
                            theDoc.content = xlstFatt;
                        }
                    }
                }

                if (!string.IsNullOrEmpty(versioneStampabile) && versioneStampabile.ToUpper().Equals("FALSE") && theDoc.estensioneFile != null && theDoc.estensioneFile.ToUpper().Equals("EML"))
                {
                    // string emlContent = FileManager.getInstance(id).getEMLContent(this, theDoc.fullName);
                    Response.ContentType = theDoc.contentType;
                    Response.AddHeader("content-disposition", "inline;filename=" + theDoc.name);
                    Response.AddHeader("content-length", theDoc.content.Length.ToString());
                    Response.BinaryWrite(theDoc.content);
                    Response.End();
                }
                else
                {
                    if (!downloadAsAttatchment)
                    {
                        Response.ContentType = theDoc.contentType;
                        Response.AddHeader("content-disposition", "inline;filename=" + theDoc.name);
                        Response.AddHeader("content-length", theDoc.content.Length.ToString());
                        Response.BinaryWrite(theDoc.content);
                        Response.End();
                    }
                    else
                    {
                        // Download del documento come attatchment
                        Response.ContentType = theDoc.contentType;
                        Response.AddHeader("content-disposition", "attachment;filename=" + theDoc.name);
                        Response.BinaryWrite(theDoc.content);
                        Response.End();
                    }
                }
            }
        }
Example #3
0
        private void ShowDocument()
        {
            // L'oggetto con le informazioni sul file da visualizzare
            DocsPaWR.FileDocumento theDoc = null;

            // La label con le informazioni sulla segnatura
            DocsPaWR.labelPdf label = new DocsPAWA.DocsPaWR.labelPdf();

            // I Parametri passati da query string
            string plusEtic     = string.Empty;
            string PosLabelPdf  = null;
            bool   tipo         = false;
            string rotazione    = null;
            string carattere    = string.Empty;
            string colore       = string.Empty;
            string orientamento = null;

            // Paramentri presenti in query string utilizzati per un rapido reprimento
            // del file del documento
            string docNumber     = String.Empty;
            string verisonId     = String.Empty;
            string versionNumber = String.Empty;
            string path          = String.Empty;
            string fileName      = String.Empty;

            // Valore booleano per indicare se il documento va visualizzato
            // nel suo formato originale
            bool visInOrig = false;

            // Se il query string contiene visInOrig impostato a 1
            // ed il ruolo è abilitato alla visualizzazione del file in
            // originale
            if (!string.IsNullOrEmpty(Request.QueryString["visInOrig"]) &&
                Request.QueryString["visInOrig"].ToString().Equals("1") &&
                UserManager.ruoloIsAutorized(this, "DO_VIS_ORIG"))
            {
                visInOrig = true;
            }

            // Lettura dei parametri per un rapido reprimenti del file
            docNumber     = Request["docNumber"];
            verisonId     = Request["versionId"];
            versionNumber = Request["versionNumber"];
            path          = Server.UrlDecode(Request["path"]);
            fileName      = Server.UrlDecode(Request["fileName"]);



            // Se in sessione non è presente un valore per docToSign...
            if (Session["docToSign"] == null)
            {
                // ...si procede con il caricamento normale del documento
                plusEtic     = Request["plusEtic"];
                PosLabelPdf  = Request["pos"];
                tipo         = System.Convert.ToBoolean(Request["tipo"]);
                rotazione    = Request["rotazione"];
                carattere    = Request["carattere"];
                colore       = Request["colore"];
                orientamento = Request["orientamento"];
                //carico i dati dentro l'oggetto Label
                label.position       = PosLabelPdf;
                label.tipoLabel      = tipo;
                label.label_rotation = rotazione;
                label.orientamento   = orientamento;
                label.sel_font       = carattere;
                label.sel_color      = colore;

                // Se bisogna visualizzare l'etichetta...
                if (!String.IsNullOrEmpty(plusEtic))
                {
                    // ...reperimento del contenuto del documento
                    theDoc = FileManager.getInstance(Session.SessionID).
                             GetFileConSegnatura(this, verisonId, versionNumber,
                                                 docNumber, path, fileName, label);
                }

                else
                {
                    bool showAsPdfFormat = false;

                    // Se visInOrig è false...
                    if (!visInOrig)
                    {
                        // ...si prova a verficare se si è abilitati a visualizzare il documento
                        // direttamente convertito in PDF
                        bool showDocumentAsPdf = false;

                        Boolean.TryParse(
                            ConfigurationManager.AppSettings["SHOW_DOCUMENT_AS_PDF_FORMAT"],
                            out showAsPdfFormat);

                        // Si preleva il file
                        if (fileName.ToUpper().EndsWith(".EML"))
                        {
                            theDoc = FileManager.getInstance(Session.SessionID).GetFileAsEML(this, verisonId, versionNumber, docNumber, path, fileName, showAsPdfFormat);
                        }
                        else
                        {
                            theDoc = FileManager.getInstance(Session.SessionID).
                                     GetFile(this, verisonId, versionNumber,
                                             docNumber, path, fileName, showAsPdfFormat);
                        }
                    }
                }
            }
            else
            {
                // ...altrimenti viene prelevato dalla sessione il documento da firmare
                theDoc = (DocsPAWA.DocsPaWR.FileDocumento)Session["docToSign"];
            }

            // Se il documento è stato reperito con successo... set datavista se richiesto.

            if (theDoc != null)
            {
                if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["SET_DATA_VISTA_GRD"]))
                {
                    if (ConfigurationManager.AppSettings["SET_DATA_VISTA_GRD"] == "1" || ConfigurationManager.AppSettings["SET_DATA_VISTA_GRD"] == "2")
                    {
                        // nella configurazione SET_DATA_VISTA_GRD=2, la visualizzazione del documento dalle griglie non deve farlo, ma il controllo sta sul BE, quindi dal FE
                        // la lascio eseguire.
                        FileManager.setdatavistaSP(UserManager.getInfoUtente(), docNumber, "D");
                    }
                }
            }

            // Se il documento è stato reperito con successo...  lo visualizzo
            if (theDoc != null)
            {
                if (theDoc.fullName.Contains("."))
                {
                    string extension = theDoc.fullName.Substring(theDoc.fullName.LastIndexOf(".") + 1);
                    if (!string.IsNullOrEmpty(extension) && extension.ToUpper().Equals("XML"))
                    {
                        theDoc.contentType = "image/jpeg";
                    }
                }
                // Si verifica se il documento deve essere scaricato o visualizzato
                // internamente
                bool downloadAsAttatchment = false;
                bool.TryParse(this.Request.QueryString["downloadAsAttatchment"], out downloadAsAttatchment);
                // verifica se l'esetnsione del file è di tipo eml
                //downloadAsAttatchment |= Path.GetExtension(theDoc.fullName).ToLower().Equals(".eml");

                // verifico se l'estensione del file è .pps
                if (Path.GetExtension(theDoc.fullName).ToLower().Equals(".pps"))
                {
                    downloadAsAttatchment = true;
                }

                // Se bisogna visualizzare esternamente...
                if (downloadAsAttatchment)
                {
                    // ...si visualizza il file come attachment
                    this.WriteResponse("attachment", theDoc);
                }
                else
                {
                    // ...altrimenti si visualizza internamente
                    this.WriteResponse("inline", theDoc);
                }
            }
            else
            {
                // ...altrimenti si redireziona l'utente alla pagina di errore
                ErrorManager.redirectToErrorPage(this, new Exception("Non è stato possibile recuperare il file"));
            }
        }