protected void Page_Load(object sender, EventArgs e) { Response.Expires = -1; try { idIstanza = Request.QueryString["idIstanza"]; tipofirma = Request.QueryString["tipofirma"]; comcomponentType = Request.QueryString["applet"]; if (string.IsNullOrEmpty(tipofirma)) { tipofirma = string.Empty; } if (tipofirma.Equals("cosign")) { firmabool = true; } else { firmabool = false; } byte[] ba = null; if (string.IsNullOrEmpty(comcomponentType)) { ba = Request.BinaryRead(Request.ContentLength); } else { string b64Content = Request["contentFile"]; if (!string.IsNullOrEmpty(b64Content)) { b64Content = b64Content.Replace(' ', '+'); b64Content = b64Content.Trim(); FileJSON file = JsonConvert.DeserializeObject <FileJSON>(b64Content); ba = Convert.FromBase64String(file.content); } } //Invia i dati al servizio wss = new ProxyManager().getProxy(); string result = wss.uploadSignedXml(idIstanza, ba, (WSConservazioneLocale.InfoUtente)Session["infoutCons"], !string.IsNullOrEmpty(comcomponentType)); Session["resultFirma"] = result; //wss.uploadSignedXml(idIstanza, ba, (WSConservazioneLocale.InfoUtente)Session["infoutCons"]); //se l'upload sul servizio avviene con successo restituisco il seguente alert di conferma!!! string confirmMsg = "Il documento firmato e' stato archiviato con successo!"; confirmMsg = confirmMsg.Replace("'", "\\'"); // Visualizzazione messaggio di errore this.RegisterClientScript("UploadSignDoc", "alert('" + confirmMsg + "');"); } catch (Exception es) { Debugger.Write("Errore nell'upload del file firmato: " + es.Message); } }
protected void Page_Load(object sender, EventArgs e) { Response.Expires = -1; try { idIstanza = Request.QueryString["idIstanza"]; comcomponentType = Request.QueryString["applet"]; wss = new ProxyManager().getProxy(); byte[] fileToSign = wss.downloadSignedXml(idIstanza, ((WSConservazioneLocale.InfoUtente)Session["infoutCons"])); if (fileToSign != null) { if (string.IsNullOrEmpty(comcomponentType)) { Response.ContentType = "application/xml"; Response.AddHeader("Content-Disposition", "inline"); Response.BinaryWrite(fileToSign); } else { string base64String = System.Convert.ToBase64String(fileToSign, 0, fileToSign.Length); Response.Write(base64String); } } } catch (Exception ex) { Debugger.Write("Errore nel download del file xml da firmare: " + ex.Message); } }
protected void BtnSign_Click(object sender, EventArgs e) { bool cofirma = false; bool timestamp = false; bool convert = false; DigitalSignature.RemoteDigitalSignManager dsm = null; DigitalSignature.RemoteDigitalSignManager.tipoFirma tipoFirma = DigitalSignature.RemoteDigitalSignManager.tipoFirma.CADES; DigitalSignature.RemoteDigitalSignManager.Memento mem = null; String alias, dominio, pin, otp; byte[] fileToSign = null; if (!string.IsNullOrEmpty(this.TxtHsmAlias.Text) && !string.IsNullOrEmpty(this.TxtHsmDomain.Text) && !string.IsNullOrEmpty(this.TxtHsmPin.Text) && !string.IsNullOrEmpty(this.TxtHsmLitOtp.Text)) { alias = this.TxtHsmAlias.Text; dominio = this.TxtHsmDomain.Text; pin = this.TxtHsmPin.Text; otp = this.TxtHsmLitOtp.Text; dsm = new DigitalSignature.RemoteDigitalSignManager(); tipoFirma = new DigitalSignature.RemoteDigitalSignManager.tipoFirma(); mem = new DigitalSignature.RemoteDigitalSignManager.Memento { Alias = alias, Dominio = dominio }; try { // D.O. 16/11/2016 le seguenti proprità non sono inizializzate in Page_Load (IsPostBack = true) // this.wss = new ProxyManager().getProxy(); this.idIstanza = Request.QueryString["idIstanza"]; this.infoUtente = ((WSConservazioneLocale.InfoUtente)Session["infoutCons"]); this.infoUtenteWR = GetInfoUtenteWR(infoUtente); dsm.HSM_SetMementoForUser(mem, this.infoUtenteWR); // fileToSign = wss.downloadSignedXml(idIstanza, this.infoUtente); dsm.HSM_SignContent(idIstanza, fileToSign, cofirma, timestamp, tipoFirma, alias, dominio, otp, pin, convert, this.infoUtenteWR); } catch (System.Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.fra_main.ajaxDialogModal('" + ex.Message + "', 'warning');} else {parent.ajaxDialogModal('" + ex.Message + "', 'warning');}", true); } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "alert('Inserire tutti i campi obbligatori.';", true); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.infoUtente = ((WSConservazioneLocale.InfoUtente)Session["infoutCons"]); this.infoUtenteWR = GetInfoUtenteWR(infoUtente);// ((DocsPaWR.InfoUtente)Session["infoutCons"]); this.idIstanza = Request.QueryString["idIstanza"]; this.wss = new ProxyManager().getProxy(); this.InitializeLanguage(); this.InitializePage(); } }
protected void Page_Load(object sender, EventArgs e) { Response.Expires = -1; try { idIstanza = Request.QueryString["idIstanza"]; wss = new ProxyManager().getProxy(); byte[] fileToSign = wss.downloadSignedXml(idIstanza, ((WSConservazioneLocale.InfoUtente)Session["infoutCons"])); //va aggiunta la chiamata al servizio con MTOM o in alternativa con DIME //System.IO.File fileFirmato = new System.IO.FileStream("timbro_orizzontale.JPG", System.IO.FileAccess.ReadWrite); if (fileToSign != null) { Response.BinaryWrite(fileToSign); } } catch (Exception ex) { Debugger.Write("Errore nel download dal servizio del file xml da visualizzare per la firma: " + ex.Message); } }
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"]; type = Request.QueryString["type"]; wss = new ProxyManager().getProxy(); // Visualizzazione xml per documento if (type == "D") { // // 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)) { // } else { // Prendo il file dallo storage //string formato = info.Split('§')[0]; string formato = "text/plain"; string idDocument = info.Split('§')[1]; string path = info.Split('§')[2]; //string hashSupporto = info.Split('§')[3]; pathFile = path + ".xml"; byte[] contentFile = wss.getFileFromStore(infoUt, idIstanza, pathFile, localStore); if (contentFile != null) { Response.ContentType = formato; Response.AddHeader("Content-Disposition", "inline"); Response.BinaryWrite(contentFile); } } } // Visualizzazione xml per fascicolo if (type == "F") { // Get Info istanze conservazione WSConservazioneLocale.ItemsConservazione[] itemsCons = ConservazioneManager.getItemsConservazione(idIstanza, infoUt); string formato = "text/plain"; string idFascicolo = idDocumento; string CodiceFascicolo = string.Empty; if (itemsCons.Length > 0) { CodiceFascicolo = itemsCons.FirstOrDefault(x => x.ID_Project.ToString() == idFascicolo).CodFasc.ToString(); } string path = "\\Fascicoli" + "\\" + CodiceFascicolo + "\\" + idFascicolo; //string hashSupporto = info.Split('§')[3]; pathFile = path + ".xml"; 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); } }
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); } }