Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            WSConservazioneLocale.FileDocumento fd = (WSConservazioneLocale.FileDocumento)Session["fileReport"];
            string content = (String)Session["valoreContent"];

            if (fd != null)
            {
                if (content == "PDF")
                {
                    Response.ContentType = "application/pdf";

                    Response.AddHeader("content-disposition", "inline;filename=" + fd.name);

                    Response.AddHeader("content-length", fd.content.Length.ToString());

                    Response.BinaryWrite(fd.content);

                    Response.End();
                }

                else
                {
                    Response.ContentType = fd.contentType;

                    Response.AddHeader("content-disposition", "inline;filename=" + fd.name);

                    Response.AddHeader("content-length", fd.content.Length.ToString());

                    Response.BinaryWrite(fd.content);

                    Response.End();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Response.Expires = -1;

            string idDocumento = this.Request.QueryString["idDocumento"];

            int indiceAllegato;

            Int32.TryParse(this.Request.QueryString["indiceAllegato"], out indiceAllegato);

            //GM per scaricare stampe firmate del registro di conservazione
            bool downloadAsAttachment;

            bool.TryParse(Request.QueryString["downloadAsAttachment"], out downloadAsAttachment);
            WSConservazioneLocale.InfoUtente    infoUtente    = (WSConservazioneLocale.InfoUtente)Session["infoutCons"];
            WSConservazioneLocale.FileDocumento fileDocumento = null;

            //GM 22-7-2013
            //gestione diversa se devo visualizzare o scaricare il documento
            if (!downloadAsAttachment)
            {
                fileDocumento = ConservazioneWA.Utils.ConservazioneManager.GetFileDocumentoNotifica(infoUtente, idDocumento, indiceAllegato);
            }
            else
            {
                fileDocumento = ConservazioneWA.Utils.ConservazioneManager.GetFileDocumentoFirmato(infoUtente, idDocumento, indiceAllegato);
            }


            if (fileDocumento != null)
            {
                if (!downloadAsAttachment)
                {
                    this.Response.ContentType = "application/pdf";
                    this.Response.AddHeader("Content-Disposition", "inline");
                    this.Response.BinaryWrite(fileDocumento.content);
                }
                else
                {
                    Response.Buffer = true;
                    Response.Clear();
                    Response.ClearHeaders();
                    Response.ContentType = "application/pdf";
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + fileDocumento.name);
                    Response.BinaryWrite(fileDocumento.content);

                    Response.Flush();
                    Response.End();
                }
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string locale     = this.Request.QueryString["locale"];
            bool   localStore = false;

            if (String.IsNullOrEmpty(locale))
            {
                locale = "false";
            }

            Boolean.TryParse(locale, out localStore);

            WSConservazioneLocale.InfoUtente infoUtente = ((WSConservazioneLocale.InfoUtente)Session["infoutCons"]);
            string file            = this.Request.QueryString["file"];
            string idConservazione = this.Request.QueryString["idC"];
            string filetype        = this.Request.QueryString["ext"];

            string[] uniSincroItems = file.Split('§');

            string path    = uniSincroItems[2];
            string formato = uniSincroItems[0];

            Response.Clear();
            byte[] bincontent = null;
            if (formato.Contains("pkcs7-mime"))
            {
                WSConservazioneLocale.FileDocumento fd = ConservazioneWA.Utils.ConservazioneManager.sbustaFileFirmato(idConservazione, path, localStore);
                Response.AddHeader("content-disposition", "inline;filename=" + fd.name);
                Response.ContentType = !string.IsNullOrEmpty(fd.contentType) ? fd.contentType : "application/octet-stream";
                bincontent           = fd.content;
                Response.AddHeader("content-length", bincontent.Length.ToString());
                Response.BinaryWrite(bincontent);
            }
            else
            {
                Response.ContentType = formato;
                Response.AddHeader("content-disposition", "inline;filename=" + uniSincroItems[1] + filetype);
                bincontent = ConservazioneWA.Utils.ConservazioneManager.getFileFromStore(infoUtente, idConservazione, path, localStore);
                Response.AddHeader("content-length", bincontent.Length.ToString());
                Response.BinaryWrite(bincontent);
                Response.Flush();
            }
            //Response.Flush();
            Response.End();
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            WSConservazioneLocale.FileDocumento fd = (WSConservazioneLocale.FileDocumento)Session["fileReport"];
            string nomeFile = fd.name;

            this.hd_nomeDoc.Value = nomeFile.Substring(0, nomeFile.Length - 4);

            Response.Expires = -1;
            if (!IsPostBack)
            {
                this.btnSalva.Attributes.Add("onmouseover", "this.className='cbtnHover';");
                this.btnSalva.Attributes.Add("onmouseout", "this.className='cbtn';");
                this.btnSalva.Attributes.Add("onClick", "DialogDownload();");
                this.btnSalva.Visible = true;

                this.btnChiudi.Attributes.Add("onmouseover", "this.className='cbtnHover';");
                this.btnChiudi.Attributes.Add("onmouseout", "this.className='cbtn';");
                this.btnChiudi.Attributes.Add("onClick", "CloseWindow();");
                this.btnChiudi.Visible = true;
            }
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Expires = -1;

            WSConservazioneLocale.InfoUtente infoUt = (WSConservazioneLocale.InfoUtente)Session["infoutCons"];
            // Per adesso Provo lacale
            bool localStore = true;

            //
            // Get isLocalStore
            localStore = ConservazioneWA.Utils.ConservazioneManager.isLocalStore();

            try
            {
                // Parametri necessari, idIstanza di conservazione, pathFile
                // Parametri passati in input dal chiamante
                idIstanza   = Request.QueryString["idIstanza"];
                idDocumento = Request.QueryString["idDoc"];

                wss = new ProxyManager().getProxy();

                //
                // Recupero il file di chiusura, in cui sono contenute tutte le informazioni
                Dictionary <String, String> documentiMemorizzati = null;
                documentiMemorizzati = ConservazioneWA.Utils.ConservazioneManager.getFilesFromUniSincro(infoUt, idIstanza, localStore);

                string info = documentiMemorizzati[idDocumento];

                if (string.IsNullOrEmpty(info))
                {
                    // Non è stato possibile recuperare il file di chiusura
                    // prendo file da locale
                    //
                    // Recupero le info sul file
                    //WSConservazioneLocale.FileDocumento fileDocumento = null;
                    fileDocumento = ConservazioneWA.Utils.ConservazioneManager.GetFileDocumentoNotifica(infoUt, idDocumento, 0);

                    if (fileDocumento != null)
                    {
                        pathFile    = fileDocumento.path;
                        ContentType = fileDocumento.contentType;

                        Response.ContentType = ContentType;
                        Response.AddHeader("Content-Disposition", "inline");
                        Response.BinaryWrite(fileDocumento.content);
                    }
                }
                else
                {
                    // Prendo il file dallo storage
                    string formato      = info.Split('§')[0];
                    string idDocument   = info.Split('§')[1];
                    string path         = info.Split('§')[2];
                    string hashSupporto = info.Split('§')[3];

                    pathFile = path;

                    byte[] contentFile = wss.getFileFromStore(infoUt, idIstanza, pathFile, localStore);

                    if (contentFile != null)
                    {
                        Response.ContentType = formato;
                        Response.AddHeader("Content-Disposition", "inline");
                        Response.BinaryWrite(contentFile);
                    }
                }
            }
            catch (Exception ex)
            {
                Debugger.Write("Errore nel download del file: " + ex.Message);
            }
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                DocsPaWR.FileDocumento theDoc = new DocsPaWR.FileDocumento();

                bool   localStore = false;
                string locale     = this.Request.QueryString["locale"];

                if (String.IsNullOrEmpty(locale))
                {
                    locale = "false";
                }

                Boolean.TryParse(locale, out localStore);


                WSConservazioneLocale.InfoUtente infoUtente = ((WSConservazioneLocale.InfoUtente)Session["infoutCons"]);
                string   file            = this.Request.QueryString["file"];
                string   idConservazione = this.Request.QueryString["idC"];
                string   filetype        = this.Request.QueryString["ext"];
                string[] uniSincroItems  = file.Split('§');

                string path    = uniSincroItems[2];
                string formato = uniSincroItems[0];
                if (formato == "image/jpg" || formato == "imagejpg")
                {
                    formato = "image/jpeg";
                }

                Response.Clear();
                string[] formatsToDownload = { "application/msword",
                                               "applicationmsword",
                                               "application/vnd.ms-excel",
                                               "applicationvnd.ms-excel",
                                               "application/vnd.ms-powerpoint",
                                               "applicationvnd.ms-powerpoint",
                                               "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                                               "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
                                               "application/vnd.openxmlformats-officedocument.presentationml.template",
                                               "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
                                               "application/vnd.openxmlformats-officedocument.presentationml.presentation",
                                               "application/vnd.openxmlformats-officedocument.presentationml.slide",
                                               "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
                                               "application/vnd.oasis.opendocument.text",
                                               "application/vnd.oasis.opendocument.spreadsheet",
                                               "application/vnd.oasis.opendocument.presentation" };

                string[] extToDownload = { ".doc",
                                           ".docx",
                                           ".ppt",
                                           ".pptx",
                                           ".xls",
                                           ".xlsx",
                                           ".odt",
                                           ".odp",
                                           ".ods",
                                           ".zip" };


                byte[] bincontent = null;

                if (formato.Contains("pkcs7-mime"))
                {
                    Response.AddHeader("content-disposition", "inline");
                    WSConservazioneLocale.FileDocumento fd = ConservazioneWA.Utils.ConservazioneManager.sbustaFileFirmato(idConservazione, path, localStore);
                    if (((IList <string>)formatsToDownload).Contains(fd.contentType) || string.IsNullOrEmpty(fd.contentType))
                    {
                        Response.ContentType = "text/html";
                        Response.Write(string.Format("<a href=\"documentDL.aspx?file={0}&idC={1}&ext={2}&locale={3}\">Per visualizzare il file clicca qui.</a>", file, idConservazione, filetype, localStore.ToString().ToLower()));
                        //Response.Write(string.Format("File non apribile nella finestra di visualizzazione. <br /><br /><a href=\"documentDL.aspx?file={0}&idC={1}&ext={2}&locale={3}\">Cliccare qui per scaricare il file.</a>", file, idConservazione, filetype,localStore.ToString().ToLower()));
                    }
                    else
                    {
                        Response.ContentType = fd.contentType;
                        bincontent           = fd.content;
                        Response.BinaryWrite(bincontent);
                    }
                }
                else if (((IList <string>)formatsToDownload).Contains(formato) || ((IList <string>)extToDownload).Contains(filetype.ToLower()))
                {
                    //Response.ContentType = "application/octet-stream";
                    //Response.AddHeader("content-disposition", "attachment;filename=" + uniSincroItems[1] + filetype);
                    //bincontent = ConservazioneWA.Utils.ConservazioneManager.getFileFromStore(infoUtente, idConservazione, path);
                    //Response.AddHeader("content-length", bincontent.Length.ToString());
                    //Response.BinaryWrite(bincontent);

                    Response.ContentType = "text/html";
                    Response.Write(string.Format("<a href=\"documentDL.aspx?file={0}&idC={1}&ext={2}&locale={3}\">Per visualizzare il file clicca qui.</a>", file, idConservazione, filetype, localStore.ToString().ToLower()));
                    //Response.Write(string.Format("File non apribile nella finestra di visualizzazione. <br /><br /><a href=\"documentDL.aspx?file={0}&idC={1}&ext={2}&locale={3}\">Cliccare qui per scaricare il file.</a>", file, idConservazione, filetype, localStore.ToString().ToLower()));
                }
                else
                {
                    Response.AddHeader("content-disposition", "inline;filename=" + uniSincroItems[1] + filetype);
                    try
                    {
                        bincontent = ConservazioneWA.Utils.ConservazioneManager.getFileFromStore(infoUtente, idConservazione, path, localStore);
                    }
                    catch
                    {
                        bincontent = ConservazioneWA.Utils.ConservazioneManager.getFileFromStore(infoUtente, idConservazione, path, false);
                    }
                    Response.ContentType = formato;
                    Response.AddHeader("content-length", bincontent.Length.ToString());
                    Response.BinaryWrite(bincontent);
                }



                //Response.TransmitFile(path);
                Response.Flush();
                Response.End();
            }
        }
Exemplo n.º 7
0
        protected void GeneraReport(string reportType)
        {
            //recupero i parametri da inserire in una lista di filtri ricerca
            List <WSConservazioneLocale.FiltroRicerca> filters = new List <WSConservazioneLocale.FiltroRicerca>();

            string esito = this.ddl_esito.SelectedItem.Value;

            if (esito == "-1")
            {
                esito = string.Empty;
            }

            string azione = this.ddl_azione.SelectedItem.Value;

            if (azione == "0")
            {
                azione = string.Empty;
            }

            filters.Add(new WSConservazioneLocale.FiltroRicerca {
                argomento = "idIstanza", valore = this.txtIdIstanza.Text
            });
            filters.Add(new WSConservazioneLocale.FiltroRicerca {
                argomento = "dataFrom", valore = this.txtDataLogFrom.Text
            });
            filters.Add(new WSConservazioneLocale.FiltroRicerca {
                argomento = "dataTo", valore = this.txtDataLogTo.Text
            });
            filters.Add(new WSConservazioneLocale.FiltroRicerca {
                argomento = "utente", valore = this.txtUtente.Text
            });
            filters.Add(new WSConservazioneLocale.FiltroRicerca {
                argomento = "azione", valore = azione
            });
            filters.Add(new WSConservazioneLocale.FiltroRicerca {
                argomento = "esito", valore = esito
            });

            string tipoReport = reportType;
            string reportKey  = "LogConservazione";

            string titoloReport = string.Format("Log Conservazione");

            WSConservazioneLocale.FileDocumento fileDoc = Utils.ConservazioneManager.getFileReport(
                filters.ToArray(),
                tipoReport,
                tipoReport,
                titoloReport,
                reportKey,
                reportKey,
                infoUtente);

            //se il report è in pdf modifico il content-type per
            //permettere la visualizzazione nel browser
            if (reportType == "PDF")
            {
                fileDoc.contentType = "application/pdf";
                fileDoc.name        = string.Format("Export_Log_{0}.pdf", DateTime.Now.ToString("dd-MM-yyyy"));
            }
            else
            {
                fileDoc.contentType = "application/vnd.ms-excel";
                fileDoc.name        = string.Format("Export_Log_{0}.xls", DateTime.Now.ToString("dd-MM-yyyy"));
            }

            if (fileDoc != null)
            {
                Session.Add("fileReport", fileDoc);
                //ClientScript.RegisterStartupScript(this.GetType(), "popupExport", "visualizzaReport();", true);
                string script = string.Format("visualizzaReport('{0}');", reportType);
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "popupReport", script, true);
                //string filePath = "c:/sviluppo/report1.pdf";
                //FileStream fileStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write);
                //fileStream.Write(fileDoc.content, 0, fileDoc.content.Length);
                //fileStream.Close();
            }
        }