protected void DetailsLFAutomaticModeModify_Click(object sender, EventArgs e) { ScriptManager.RegisterStartupScript(this, this.GetType(), "reallowOp", "reallowOp();", true); //Estraggo dalla lista il processo in esecuzione IstanzaProcessoDiFirma istanza = (from i in ListaIstanzaProcessoDiFirma where string.IsNullOrEmpty(i.dataChiusura) select i).FirstOrDefault(); OpzioniNotifica opzioniNotifiche = new OpzioniNotifica(); opzioniNotifiche.Notifica_concluso = this.cbxNotificationOption.Items.FindByValue("cbxNotificationOptionOptCP").Selected; opzioniNotifiche.Notifica_interrotto = this.cbxNotificationOption.Items.FindByValue("cbxNotificationOptionOptIP").Selected; ListItem cbxErrore = this.cbxNotificationOption.Items.FindByValue("cbxNotificationOptionOptErrorePassoAutomaticoP"); opzioniNotifiche.NotificaErrore = cbxErrore != null && cbxErrore.Selected; ListItem cbxDestNonInterop = this.cbxNotificationOption.Items.FindByValue("cbxNotificationOptionOptDestNonInterop"); opzioniNotifiche.NotificaPresenzaDestNonInterop = cbxDestNonInterop != null && cbxDestNonInterop.Selected; istanza.Notifiche = opzioniNotifiche; if (LibroFirmaManager.UpdateIstanzaProcessoDiFirma(istanza)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.fra_main.ajaxDialogModal('SuccessModifyIstanzaProcesso', 'check', '');} else {parent.ajaxDialogModal('SuccessModifyIstanzaProcesso', 'check', '');}", true); return; } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.fra_main.ajaxDialogModal('ErrorModifyIstanzaProcesso', 'error', '');} else {parent.ajaxDialogModal('ErrorModifyIstanzaProcesso', 'error', '');}", true); return; } }
protected void BtnConfirm_Click(object sender, EventArgs e) { ScriptManager.RegisterStartupScript(this, this.GetType(), "reallowOp", "reallowOp();", true); // Lista di system id degli elementi selezionati List <MassiveOperationTarget> selectedItem; // Errore verificatosi in fase di creazione della scheda String error = String.Empty; // La scheda documento creata SchedaDocumento document; // Recupero della lista dei system id dei documenti selezionati selectedItem = MassiveOperationUtils.GetSelectedItems(); // Generazione della scheda MassiveOperationReport report = new MassiveOperationReport(); //Se per uno dei documenti selezionati è attivo un processo di firma, blocco l'operazione di inoltro bool inLibroFirma = false; try { foreach (MassiveOperationTarget temp in selectedItem) { if (LibroFirmaManager.IsDocOrAllInLibroFirma(temp.Id)) { report.AddReportRow("-", MassiveOperationReport.MassiveOperationResultEnum.KO, "Il documento non è stato creato poichè per uno dei documenti selezionati, o suoi allegati, è attivo un processo di firma"); inLibroFirma = true; break; } } if (!inLibroFirma) { document = this.GenerateDocumentScheda(selectedItem, out error); if (document != null) { report.AddReportRow("-", MassiveOperationReport.MassiveOperationResultEnum.OK, "Il documento è stato creato correttamente"); } else { report.AddReportRow("-", MassiveOperationReport.MassiveOperationResultEnum.KO, "Il documento non è stato creato"); } } } catch (Exception ex) { report.AddReportRow("-", MassiveOperationReport.MassiveOperationResultEnum.KO, "Errore nella creazione del documento"); } string[] pars = new string[] { "" + report.Worked, "" + report.NotWorked }; report.AddSummaryRow("Documenti lavorati: {0} - Documenti non lavorati: {1}", pars); this.generateReport(report, "Inoltra massivo"); // set session to manage document.aspx HttpContext.Current.Session["IsForwarded"] = true; }
protected void InterruptionSignatureProcessOk_Click(object sender, EventArgs e) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "function", "reallowOp();", true); try { if (!string.IsNullOrEmpty(Request.QueryString["from"])) { MotivoRespingimento = this.TxtTextAbortRecord.Text; ScriptManager.RegisterStartupScript(this, this.GetType(), "closeMask", "if (parent.fra_main) {parent.fra_main.closeAjaxModal('InterruptionSignatureProcess', '');} else {parent.closeAjaxModal('InterruptionSignatureProcess', 'up', parent);};", true); } else { string idDocPrinc = HttpContext.Current.Session["idDocPrinc"].ToString(); if (LibroFirmaManager.InterruptionSignatureProcessByProponent(IstanzaProcessoDiFirma, this.TxtTextAbortRecord.Text, idDocPrinc)) { IstanzaProcessoDiFirma.MotivoRespingimento = this.TxtTextAbortRecord.Text; IstanzaProcessoDiFirma.dataChiusura = DateTime.Now.ToString(); IstanzaProcessoDiFirma.statoProcesso = TipoStatoProcesso.STOPPED; IstanzaProcessoDiFirma.ChaInterroDa = 'P'; IstanzaProcessoDiFirma.DescUtenteInterruzione = UserManager.GetUserInSession().descrizione; if (UIManager.UserManager.getUtenteDelegato() != null) { IstanzaProcessoDiFirma.DescUtenteDelegatoInterruzione = UIManager.UserManager.getUtenteDelegato().descrizione; } ScriptManager.RegisterStartupScript(this, this.GetType(), "closeMask", "if (parent.fra_main) {parent.fra_main.closeAjaxModal('InterruptionSignatureProcess', 'up');} else {parent.closeAjaxModal('InterruptionSignatureProcess', 'up', parent);};", true); } else { string msg = "ErrorInterruptionSignatureProcess"; ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.parent.fra_main.ajaxDialogModal('" + msg.Replace("'", @"\'") + "', 'error', '');} else {parent.parent.ajaxDialogModal('" + msg.Replace("'", @"\'") + "', 'error', '');}", true); return; } } } catch (Exception ex) { string msg = "ErrorInterruptionSignatureProcess"; ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.parent.fra_main.ajaxDialogModal('" + msg.Replace("'", @"\'") + "', 'error', '');} else {parent.parent.ajaxDialogModal('" + msg.Replace("'", @"\'") + "', 'error', '');}", true); return; } }
private void InitializePage() { string docnumber = string.Empty; if (Request.QueryString["caller"] != null) { docnumber = ListaElementiSelezionati[0].InfoDocumento.Docnumber; } else { DocsPaWR.FileRequest fileReq = null; if (FileManager.GetSelectedAttachment() == null) { fileReq = UIManager.FileManager.getSelectedFile(); } else { fileReq = FileManager.GetSelectedAttachment(); } docnumber = fileReq.docNumber; } this.ListaIstanzaProcessoDiFirma = LibroFirmaManager.GetIstanzaProcessoDiFirma(docnumber); //Estraggo dalla lista il processo in esecuzione IstanzaProcessoDiFirma istanza = (from i in ListaIstanzaProcessoDiFirma where string.IsNullOrEmpty(i.dataChiusura) select i).FirstOrDefault(); if (istanza != null) { PopolaDettalioIstanza(istanza); BindTreeViewStateSignatureProcess(istanza); EnableContentProponent(istanza); } else { this.pnlDetailsSignatureProcess.Visible = false; this.DetailsLFAutomaticModeInterruption.Visible = false; this.DetailsLFAutomaticModeModify.Visible = false; } }
private TreeNode AddChildrenElements(IstanzaPassoDiFirma p, ref TreeNode root, bool isConcluted, bool isInterrupted, char interrottoDa) { TreeNode nodeChild = new TreeNode(); string text; nodeChild.ImageUrl = p.statoPasso.Equals(TipoStatoPasso.CUT) ? LibroFirmaManager.GetIconEventTypeDisabled(p) : LibroFirmaManager.GetIconEventType(p); nodeChild.Value = p.idPasso; text = p.statoPasso.Equals(TipoStatoPasso.CUT) ? "<div class ='disabled'>" + LibroFirmaManager.GetHolder(p) + "</div>" : LibroFirmaManager.GetHolder(p); nodeChild.Text = text; nodeChild.ToolTip = LibroFirmaManager.GetHolder(p); nodeChild.SelectAction = TreeNodeSelectAction.None; if (!string.IsNullOrEmpty(p.Note)) { TreeNode nodeChildNote = new TreeNode(); text = p.statoPasso.Equals(TipoStatoPasso.CUT) ? "<div class ='disabled'>" + p.Note + "</div>" : p.Note; nodeChildNote.Text = text; nodeChildNote.ToolTip = p.Note; nodeChildNote.SelectAction = TreeNodeSelectAction.None; nodeChild.ChildNodes.Add(nodeChildNote); } if (!string.IsNullOrEmpty(p.dataEsecuzione)) { TreeNode nodeChildDateExecution = new TreeNode(); string user = Utils.Languages.GetLabelFromCode("DetailsLFAutomaticModeUserLocker", UserManager.GetUserLanguage()) + " " + p.DescrizioneUtenteLocker; string action = p.statoPasso.Equals(TipoStatoPasso.CLOSE) ? Utils.Languages.GetLabelFromCode("DetailsLFAutomaticModeEseguitoIl", UserManager.GetUserLanguage()) : Utils.Languages.GetLabelFromCode("DetailsLFAutomaticModeInterrottoIl", UserManager.GetUserLanguage()); text = p.statoPasso.Equals(TipoStatoPasso.CUT) ? "<div class ='disabled'>" + action + " " + p.dataEsecuzione + " " + user + "</div>" : action + " " + p.dataEsecuzione + " " + user; nodeChildDateExecution.Text = text; nodeChildDateExecution.SelectAction = TreeNodeSelectAction.None; nodeChild.ChildNodes.Add(nodeChildDateExecution); } if (!string.IsNullOrEmpty(p.Errore)) { TreeNode nodeChildNote = new TreeNode(); text = FormatError(p.Errore); nodeChildNote.Text = text; nodeChildNote.ToolTip = text; nodeChildNote.SelectAction = TreeNodeSelectAction.None; nodeChildNote.ImageUrl = "../Images/Icons/task_in_corso.png"; nodeChild.ChildNodes.Add(nodeChildNote); } root.ChildNodes.Add(nodeChild); if (p.statoPasso.Equals(TipoStatoPasso.LOOK) && !isConcluted) { nodeChild.Select(); } if (p.statoPasso.Equals(TipoStatoPasso.LOOK) && isInterrupted && interrottoDa != '0') { TreeNode nodeChildDateExecution = new TreeNode(); switch (interrottoDa) { case PROPONENTE: nodeChildDateExecution.Text = Utils.Languages.GetLabelFromCode("DetailsLFAutomaticModeInterruptedByProponente", UserManager.GetUserLanguage()); break; case AMMINISTRATORE: nodeChildDateExecution.Text = Utils.Languages.GetLabelFromCode("DetailsLFAutomaticModeInterruptedByAmministrazione", UserManager.GetUserLanguage()); break; default: nodeChildDateExecution.Text = Utils.Languages.GetLabelFromCode("DetailsLFAutomaticModeInterrupted", UserManager.GetUserLanguage()); break; } nodeChildDateExecution.SelectAction = TreeNodeSelectAction.None; nodeChild.ChildNodes.Add(nodeChildDateExecution); } return(nodeChild); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); DocsPaWR.FileRequest fileReq = null; if (FileManager.GetSelectedAttachment() == null) { fileReq = UIManager.FileManager.getSelectedFile(); } else { fileReq = FileManager.GetSelectedAttachment(); } if (!string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString())) && Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString()).Equals("1")) { bool isPdf = (FileManager.getEstensioneIntoSignedFile(fileReq.fileName).ToUpper() == "PDF"); if (!isPdf && !fileReq.firmato.Equals("1")) { this.chkConverti.Checked = true; if (UIManager.FileManager.IsEnabledSupportedFileTypes()) { this.FileTypes = UIManager.FileManager.GetSupportedFileTypes(Int32.Parse(UIManager.UserManager.GetInfoUser().idAmministrazione)); bool retVal = true; int count = this.FileTypes.Count(e => e.FileExtension.ToLowerInvariant() == FileManager.getEstensioneIntoSignedFile(fileReq.fileName).ToLowerInvariant() && e.FileTypeUsed && e.FileTypeSignature); retVal = (count > 0); this.chkConverti.Checked = !retVal; } this.chkPades.Visible = false; } else { this.chkPades.Visible = true; //Se il documento è in libro firma non posso scegliere il tipo firma, ma di pende dal passo. if (fileReq.inLibroFirma) { this.chkPades.Enabled = false; string typeSignature = LibroFirmaManager.GetTypeSignatureToBeEntered(fileReq); if (typeSignature.Equals(LibroFirmaManager.TypeEvent.SIGN_PADES)) { this.chkPades.Checked = true; } } } // this.chkConverti.Enabled = false; if (!signHash) // se non posso firmare con l'HASH allora non posso neanche firmare pades { this.chkPades.Visible = false; } //if (string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue("0", DBKeys.LOCK_COFIRMA.ToString())) || Utils.InitConfigurationKeys.GetValue("0", DBKeys.LOCK_COFIRMA.ToString()).Equals("0")) ScriptManager.RegisterStartupScript(this, this.GetType(), "clickconvertpdf", "$(function() {OnClickConvertPDF();});", true); } else { //Se il documento è in libro firma non posso scegliere il tipo firma, ma di pende dal passo. if (fileReq.inLibroFirma) { this.chkPades.Enabled = false; string typeSignature = LibroFirmaManager.GetTypeSignatureToBeEntered(fileReq); if (typeSignature.Equals(LibroFirmaManager.TypeEvent.SIGN_PADES)) { this.chkPades.Checked = true; } } this.chkConverti.Attributes.Add("onClick", "OnClickConvertPDF();"); } //PDZ - Nuova gestione firma/cofirma //Valore della Chiave FE_SET_TIPO_FIRMA // 0: Annidata // 1: Parallela // 2: Annidata non modificabile // 3: Parallela non modificabile if (fileReq.firmato.Equals("0") || fileReq.tipoFirma == NttDataWA.Utils.TipoFirma.ELETTORNICA) { this.tipoFirmaH.Value = "true"; this.optFirma.Visible = false; this.optCofirma.Visible = false; } string setTipoFirma = string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue("0", DBKeys.FE_SET_TIPO_FIRMA.ToString())) ? "0" : Utils.InitConfigurationKeys.GetValue("0", DBKeys.FE_SET_TIPO_FIRMA.ToString()); switch (setTipoFirma) { //Annidata default ma modificabile case ("0"): this.optCofirma.Checked = false; this.optFirma.Checked = true; this.optCofirma.Enabled = true; this.optFirma.Enabled = true; break; //Parallela default ma modificabile case ("1"): this.optCofirma.Checked = true; this.optFirma.Checked = false; this.optFirma.Enabled = true; this.optFirma.Enabled = true; break; //Annidata non modificabile case ("2"): this.optCofirma.Checked = false; this.optFirma.Checked = true; this.optCofirma.Enabled = false; this.optFirma.Enabled = false; break; //Parallela non modificabile case ("3"): this.optCofirma.Checked = true; this.optFirma.Checked = false; this.optFirma.Enabled = false; this.optFirma.Enabled = false; break; } }
/// <summary> /// Inserimento di un nuovo allegato per un documento /// </summary> /// <param name="infoUtente"></param> /// <param name="allegato"></param> /// <param name="debug"></param> /// <returns></returns> private static DocsPaVO.documento.Allegato aggiungiAllegato(DocsPaVO.utente.InfoUtente infoUtente, DocsPaVO.documento.Allegato allegato, bool statoCongelato) { using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext()) { if (allegato.repositoryContext != null) { // Inserimento di un allegato nel repositorycontext allegato.version = "1"; // Prima versione dell'allegato allegato.versionId = allegato.position.ToString(); // Viene assegnato un nuovo id temporaneo (la sequenza di inserimento) allegato.versionLabel = DocsPaDB.Query_DocsPAWS.Documenti.FormatCodiceAllegato(allegato.position); // Viene creato, in base alla sequenza di inserimento, il codice progressivo // L'allegato viene impostato come non acquisito allegato.subVersion = "!"; allegato.fileName = string.Empty; allegato.fileSize = "0"; } else { if (statoCongelato && allegato.TypeAttachment != 2 && allegato.TypeAttachment != 3) { // Controllo su stato congelato, solo se non si sta creando l'allegato nel repository context DocumentConsolidation.CanExecuteAction(infoUtente, allegato.docNumber, DocumentConsolidation.ConsolidationActionsDeniedEnum.AddAttatchments, true); } DocsPaDB.Query_DocsPAWS.Documenti doc = new DocsPaDB.Query_DocsPAWS.Documenti(); string oldApp = null; string putfile = ""; try { if (allegato.applicazione != null) { if (allegato.applicazione.systemId == null) { allegato.applicazione = BusinessLogic.Documenti.FileManager.getApplicazione(allegato.applicazione.estensione); } logger.Debug("Update della tabella profile"); string param = "DOCNUMBER=" + allegato.docNumber; doc.GetApplication(out oldApp, allegato.docNumber, allegato.applicazione.systemId, param); } if (!string.IsNullOrEmpty(allegato.versionLabel)) { // L'allegato è già stato creato (ha già la versionLabel), // si sta usando il metodo per fare un'acquisizione sull'allegato putfile = "Y"; } DocsPaDocumentale.Documentale.DocumentManager documentManager = new DocsPaDocumentale.Documentale.DocumentManager(infoUtente); //Se l'allegato non è una ricevuta controllo se il doc principale è in libro firma; se il doc principale è in libro firma non è possibile allegare if (allegato.TypeAttachment != 2 && allegato.TypeAttachment != 3 && LibroFirmaManager.IsModificaBloccataPerDocumentoPrincipaleInLF(allegato.docNumber, infoUtente.idAmministrazione)) { throw new Exception("Non è possibile creare l'allegato poichè il documento principale è in libro firma"); } if (!documentManager.AddAttachment(allegato, putfile)) { throw new Exception("Errore nell'inserimento dell'allegato nel documentale"); } else { transactionContext.Complete(); } } catch (Exception e) { string message = string.Format("Errore nell'inserimento dell'allegato: {0}", e.Message); logger.Debug(message); throw new Exception(message); } } } return(allegato); }
private void InitializeKeys() { DocsPaWR.FileRequest fileReq = null; if (FileManager.GetSelectedAttachment() == null) { fileReq = UIManager.FileManager.getSelectedFile(); } else { fileReq = FileManager.GetSelectedAttachment(); } if (!string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString())) && Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString()).Equals("1")) { bool isPdf = (FileManager.getEstensioneIntoSignedFile(fileReq.fileName).ToUpper() == "PDF"); //if (string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue("0", DBKeys.FE_LIBRO_FIRMA.ToString())) || Utils.InitConfigurationKeys.GetValue("0", DBKeys.FE_LIBRO_FIRMA.ToString()).Equals("0")) //{ // //E' spento il libro firma e quindi rimane la normale gestione della co-firma //} //Modifica condizioni Libro Firma per APSS: se il libro firma è attivo ma è abilitata UNLOCK_COFIRMA ripristino la selezione del tipo firma(firma/cofirma) //else if (!string.IsNullOrEmpty(fileReq.firmato) && fileReq.firmato.Trim() == "1" && // (string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue("0", DBKeys.UNLOCK_COFIRMA.ToString())) || Utils.InitConfigurationKeys.GetValue("0", DBKeys.UNLOCK_COFIRMA.ToString()).Equals("0"))) //{ // //E' attivo il libro firma e quindi se è già firmato, appone sempre co-firma // forzaCofirma = true; //} if (!isPdf && !fileReq.firmato.Equals("1")) { this.chkConverti.Checked = true; this.chkConverti.Enabled = false; if (UIManager.FileManager.IsEnabledSupportedFileTypes()) { this.FileTypes = UIManager.FileManager.GetSupportedFileTypes(Int32.Parse(UIManager.UserManager.GetInfoUser().idAmministrazione)); bool retVal = true; int count = this.FileTypes.Count(e => e.FileExtension.ToLowerInvariant() == FileManager.getEstensioneIntoSignedFile(fileReq.fileName).ToLowerInvariant() && e.FileTypeUsed && e.FileTypeSignature); retVal = (count > 0); this.chkConverti.Checked = !retVal; } this.chkPades.Visible = false; } else { this.chkPades.Visible = true; this.chkConverti.Enabled = false; //Se il documento è in libro firma non posso scegliere il tipo firma, ma di pende dal passo. if (fileReq.inLibroFirma) { this.chkPades.Enabled = false; string typeSignature = LibroFirmaManager.GetTypeSignatureToBeEntered(fileReq); if (typeSignature.Equals(LibroFirmaManager.TypeEvent.SIGN_PADES)) { this.chkPades.Checked = true; } } } } if (!signHash) // se non posso firmare con l'HASH allora non posso neanche firmare pades { this.chkPades.Visible = false; } //Se il documento è in libro firma non posso scegliere il tipo firma, ma di pende dal passo. if (fileReq.inLibroFirma) { this.chkPades.Enabled = false; string typeSignature = LibroFirmaManager.GetTypeSignatureToBeEntered(fileReq); if (typeSignature.Equals(LibroFirmaManager.TypeEvent.SIGN_PADES)) { this.chkPades.Checked = true; } } //PDZ - Nuova gestione firma/cofirma //Valore della Chiave FE_SET_TIPO_FIRMA // 0: Annidata // 1: Parallela // 2: Annidata non modificabile // 3: Parallela non modificabile if (fileReq.firmato.Equals("0") || fileReq.tipoFirma == NttDataWA.Utils.TipoFirma.ELETTORNICA) { this.tipoFirmaH.Value = "true"; this.optFirma.Visible = false; this.optCofirma.Visible = false; } string setTipoFirma = string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue("0", DBKeys.FE_SET_TIPO_FIRMA.ToString())) ? "0" : Utils.InitConfigurationKeys.GetValue("0", DBKeys.FE_SET_TIPO_FIRMA.ToString()); switch (setTipoFirma) { //Annidata default ma modificabile case ("0"): this.optCofirma.Checked = false; this.optFirma.Checked = true; this.optCofirma.Enabled = true; this.optFirma.Enabled = true; break; //Parallela default ma modificabile case ("1"): this.optCofirma.Checked = true; this.optFirma.Checked = false; this.optFirma.Enabled = true; this.optFirma.Enabled = true; break; //Annidata non modificabile case ("2"): this.optCofirma.Checked = false; this.optFirma.Checked = true; this.optCofirma.Enabled = false; this.optFirma.Enabled = false; break; //Parallela non modificabile case ("3"): this.optCofirma.Checked = true; this.optFirma.Checked = false; this.optFirma.Enabled = false; this.optFirma.Enabled = false; break; } }
private string CheckSign(SchedaDocumento schedaDoc) { string msgError = string.Empty; FileRequest fileReq = schedaDoc.documenti[0]; bool isPdf = (FileManager.getEstensioneIntoSignedFile(fileReq.fileName).ToUpper() == "PDF"); string estenxione = FileManager.getEstensioneIntoSignedFile(fileReq.fileName).ToLowerInvariant(); #region FILE NON ACQUISITO if (string.IsNullOrEmpty(fileReq.fileSize) || int.Parse(fileReq.fileSize) == 0) { msgError = "Il file non risulta acquisito, quindi non è possibile applicare la firma HSM."; return(msgError); } #endregion #region VERIFICA ESTENSIONE DEL FILE if (string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString())) || !Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString()).Equals("1")) { if (IsEnabledSupportedFileTypes) { int count = this.FileTypes.Count(e => e.FileExtension.ToLowerInvariant() == estenxione && e.FileTypeUsed && e.FileTypeSignature); bool retVal = (count > 0); if (!retVal) { msgError = "Non è stato possibile firmare il documento. Effettuare la conversione in PDF del file."; return(msgError); } } } #endregion #region VERIFICA DIMENSIONE FILE if (this.MaxDimFileSign > 0 && Convert.ToInt32(schedaDoc.documenti[0].fileSize) > this.MaxDimFileSign) { string maxSize = Convert.ToString(Math.Round((double)this.MaxDimFileSign / 1048576, 3)); msgError = "La dimensione del file supera il limite massimo consentito per la firma. Il limite massimo consentito è: " + maxSize + " Mb."; return(msgError); } #endregion #region DOCUMENTO ANNULLATO if (schedaDoc.protocollo != null && schedaDoc.protocollo.protocolloAnnullato != null && !string.IsNullOrEmpty(schedaDoc.protocollo.protocolloAnnullato.dataAnnullamento)) { msgError = "Il file non è stato firmato in quanto il protocollo risulta annullato."; return(msgError); } #endregion #region DOCUMENTO IN CESTINO if (schedaDoc.inCestino != null && schedaDoc.inCestino == "1") { msgError = "Il file non è stato firmato in quanto il documento è stato rimosso."; return(msgError); } #endregion #region DOCUMENTO CONSOLIDATO if (schedaDoc.ConsolidationState != null && schedaDoc.ConsolidationState.State != DocsPaWR.DocumentConsolidationStateEnum.None) { msgError = "Il file non è stato firmato in quanto il documento è consolidato."; return(msgError); } #endregion #region DOCUMENTO IN CHECKOUT if (schedaDoc.checkOutStatus != null && !string.IsNullOrEmpty(schedaDoc.checkOutStatus.ID)) { msgError = "Il file non è stato firmato in quanto il documento è bloccato."; return(msgError); } #endregion #region DOCUMENTO IN SOLA LETTURA if (Convert.ToInt32(schedaDoc.accessRights) == Convert.ToInt32(HMdiritti.HMdiritti_Read)) { msgError = "Il file non è stato firmato in quanto il documento è in sola lettura."; return(msgError); } #endregion #region DOCUMENTO IN ATTESA DI ACCETTAZIONE if (Convert.ToInt32(schedaDoc.accessRights) == Convert.ToInt32(HMdiritti.HDdiritti_Waiting)) { msgError = "Il file non è stato firmato in quanto il documento è in attesa di accettazione."; return(msgError); } #endregion #region FIRMA PADES //Controllo che il file che stò firmando è un PDF if (this.HsmRadioSign.Checked) { if (!isPdf && this.HsmLitPades.Checked) { msgError = "Non è possibile firmare pades un documento non pdf. Effettuare la conversione in PDF del file"; return(msgError); } } System.IO.FileInfo fileInfo = new System.IO.FileInfo(fileReq.fileName); bool isCadesSign = (fileInfo != null && !String.IsNullOrEmpty(fileInfo.Extension) && fileInfo.Extension.ToLower().Equals(".p7m")); //bool isCadesSign = (!String.IsNullOrEmpty(fileReq.tipoFirma) && fileReq.tipoFirma.Equals(TipoFirma.CADES)) || (fileInfo != null && !String.IsNullOrEmpty(fileInfo.Extension) && fileInfo.Extension.ToLower().Equals(".p7m")); if (this.HsmLitPades.Checked && isCadesSign) { msgError = "Non è possibile applicare una firma PADES su di un file firmato CADES"; return(msgError); } #endregion #region COFIRMA //if (this.HsmRadioCoSign.Checked) //{ ////Non posso cofirmare PADES //if (this.HsmLitPades.Checked) //{ // msgError = "Non è possibile applicare la cofirma PADES su file firmato"; // return msgError; //} // if (this.HsmLitP7M.Checked && (fileReq.tipoFirma == TipoFirma.PADES || fileReq.tipoFirma == TipoFirma.PADES_ELETTORNICA)) //{ //Non posso firmare CADES un file firmato PADES :se l'estensione del file è PDF, il file è stato firmato PADES // msgError = "Non è possibile applicare la cofirma CADES su file firmato PADES"; // return msgError; //} // } #endregion #region VERFICA SE è OBBLIGATORIA LA CONVERSIONE IN PDF DEL FILE if (!isPdf) { if (!string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString())) && Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString()).Equals("1")) { if (IsEnabledSupportedFileTypes) { bool retVal = true; int count = this.FileTypes.Count(f => f.FileExtension.ToLowerInvariant() == estenxione && f.FileTypeUsed && f.FileTypeSignature); retVal = (count > 0); if (!retVal) { msgError = "Non è stato possibile firmare il documento. Effettuare la conversione in PDF del file."; return(msgError); } } } } #endregion //MEV LIBRO FIRMA #region TIPO FIRMA DA APPORRE if (!IsLF && fileReq.inLibroFirma) { string typeSignature = LibroFirmaManager.GetTypeSignatureToBeEntered(fileReq); if (this.HsmLitP7M.Checked && !typeSignature.Equals(LibroFirmaManager.TypeEvent.SIGN_CADES)) { msgError = "Documento in Libro firma. La tipologia di firma selezionata non corrisponde a quella richiesta"; return(msgError); } else if (this.HsmLitPades.Checked && !typeSignature.Equals(LibroFirmaManager.TypeEvent.SIGN_PADES)) { msgError = "Documento in Libro firma. La tipologia di firma selezionata non corrisponde a quella richiesta"; return(msgError); } } #endregion return(msgError); }
private void InitializePage() { this.popolaCampiMemento(); DocsPaWR.FileRequest fileReq = null; if (FileManager.GetSelectedAttachment() == null) { fileReq = UIManager.FileManager.getSelectedFile(); } else { fileReq = FileManager.GetSelectedAttachment(); } if (UIManager.UserManager.IsAuthorizedFunctions("TO_GET_OTP")) { this.BtnRequestOTP.Visible = true; } if (!string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString())) && Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString()).Equals("1")) { bool isPdf = (FileManager.getEstensioneIntoSignedFile(fileReq.fileName).ToUpper() == "PDF"); if (!isPdf && !fileReq.firmato.Equals("1")) { this.HsmCheckConvert.Checked = true; if (UIManager.FileManager.IsEnabledSupportedFileTypes()) { this.FileTypes = UIManager.FileManager.GetSupportedFileTypes(Int32.Parse(UIManager.UserManager.GetInfoUser().idAmministrazione)); bool retVal = true; int count = this.FileTypes.Count(e => e.FileExtension.ToLowerInvariant() == FileManager.getEstensioneIntoSignedFile(fileReq.fileName).ToLowerInvariant() && e.FileTypeUsed && e.FileTypeSignature); retVal = (count > 0); //INC000000778865 - PROBLEMA CON MASCHERA DI FIRMA HSM //this.HsmCheckConvert.Checked = retVal; } } this.HsmCheckConvert.Enabled = false; setCofirma(fileReq.firmato == "1" ? true : false); //ABBATANGELI - nuova gestione sign/cosign //MEV LIBRO FIRMA //if (!string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue("0", DBKeys.FE_LIBRO_FIRMA.ToString())) && Utils.InitConfigurationKeys.GetValue("0", DBKeys.FE_LIBRO_FIRMA.ToString()).Equals("1")) //{ // this.PnlTypeSign.Visible = false; //} } //se il documento è in libro firma, forzo la selezione al radio button relativo al tipo di firma richiesto if (fileReq.inLibroFirma) { this.HsmLitPades.Enabled = false; this.HsmLitP7M.Enabled = false; string typeSignature = LibroFirmaManager.GetTypeSignatureToBeEntered(fileReq); if (typeSignature.Equals(LibroFirmaManager.TypeEvent.SIGN_PADES)) { this.HsmLitPades.Checked = true; this.HsmLitP7M.Checked = false; } else { this.HsmLitPades.Checked = false; this.HsmLitP7M.Checked = true; } } //ABBATANGELI - Nuova gestione firma/cofirma //if (string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue("0", DBKeys.LOCK_COFIRMA.ToString())) || Utils.InitConfigurationKeys.GetValue("0", DBKeys.LOCK_COFIRMA.ToString()).Equals("0")) //Valore della Chiave FE_SET_TIPO_FIRMA // 0: Annidata // 1: Parallela // 2: Annidata non modificabile // 3: Parallela non modificabile string setTipoFirma = string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue("0", DBKeys.FE_SET_TIPO_FIRMA.ToString())) ? "0" : Utils.InitConfigurationKeys.GetValue("0", DBKeys.FE_SET_TIPO_FIRMA.ToString()); if (setTipoFirma.Equals("0") || setTipoFirma.Equals("2")) { this.optFirma.Checked = true; if (fileReq.firmato.Equals("1")) { bool enabledRadio = setTipoFirma.Equals("0"); this.optCofirma.Enabled = enabledRadio; this.optFirma.Enabled = enabledRadio; } else { this.optCofirma.Enabled = false; this.optFirma.Enabled = false; } } else { if (fileReq.firmato.Equals("1") && !fileReq.tipoFirma.Equals(NttDataWA.Utils.TipoFirma.ELETTORNICA)) { this.optCofirma.Checked = true; bool enabledRadio = setTipoFirma.Equals("1"); this.optCofirma.Enabled = enabledRadio; this.optFirma.Enabled = enabledRadio; } else { this.optFirma.Checked = true; this.optCofirma.Enabled = false; this.optFirma.Enabled = false; } } this.TxtHsmPin.Focus(); }
protected void SignatureSelectedItemsConfirm_Click(object sender, EventArgs e) { bool noDigitalSign = true; try { ReportSignatureSelected = new MassiveOperationReport(); //MassiveOperationReport report = new MassiveOperationReport(); MassiveOperationUtils.ItemsStatus = null; MassiveOperationReport.MassiveOperationResultEnum result; string oggetto = string.Empty; string details; string popupCall = string.Empty; List <FileRequest> fileReqToSign = new List <FileRequest>(); this.ListIdDocumentSigned = new List <string>(); Allegato attach; Documento doc; #region AVANZAMENTO ITER List <ElementoInLibroFirma> listElementAdvancementProcess = (from i in this.ListaElementiLibroFirma where i.TipoFirma.Equals(LibroFirmaManager.TypeEvent.ADVANCEMENT_PROCESS) && i.StatoFirma.Equals(TipoStatoElemento.DA_FIRMARE) select i).ToList(); if (listElementAdvancementProcess != null && listElementAdvancementProcess.Count > 0) { foreach (ElementoInLibroFirma element in listElementAdvancementProcess) { if (string.IsNullOrEmpty(element.InfoDocumento.IdDocumentoPrincipale)) { doc = new Documento() { descrizione = element.InfoDocumento.Oggetto, docNumber = element.InfoDocumento.Docnumber, versionId = element.InfoDocumento.VersionId, version = element.InfoDocumento.NumVersione.ToString(), versionLabel = element.InfoDocumento.NumAllegato.ToString(), inLibroFirma = true }; fileReqToSign.Add(doc as FileRequest); } else { attach = new Allegato() { descrizione = element.InfoDocumento.Oggetto, docNumber = element.InfoDocumento.Docnumber, versionId = element.InfoDocumento.VersionId, version = element.InfoDocumento.NumVersione.ToString(), versionLabel = element.InfoDocumento.NumAllegato.ToString(), inLibroFirma = true }; fileReqToSign.Add(attach as FileRequest); } } bool isAdvancementProcess = true; List <FirmaResult> firmaResult = LibroFirmaManager.PutElectronicSignatureMassive(fileReqToSign, isAdvancementProcess); if (firmaResult != null) { foreach (FirmaResult r in firmaResult) { if (string.IsNullOrEmpty(r.errore)) { result = MassiveOperationReport.MassiveOperationResultEnum.OK; details = "Avanzamento iter avvenuto con successo"; oggetto = r.fileRequest.descrizione; ReportSignatureSelected.AddReportRow( oggetto, result, details); ListIdDocumentSigned.Add(r.fileRequest.docNumber); } else { result = MassiveOperationReport.MassiveOperationResultEnum.KO; oggetto = r.fileRequest.descrizione; details = String.Format( "Si sono verificati degli errori durante la procedura di avanzamento. {0}", r.errore); ReportSignatureSelected.AddReportRow( oggetto, result, details); } } } } #endregion #region SOTTOSCRIZIONE fileReqToSign.Clear(); List <ElementoInLibroFirma> listElementSubscription = (from i in this.ListaElementiLibroFirma where i.TipoFirma.Equals(LibroFirmaManager.TypeEvent.VERIFIED) && i.StatoFirma.Equals(TipoStatoElemento.DA_FIRMARE) select i).ToList(); if (listElementSubscription != null && listElementSubscription.Count > 0) { foreach (ElementoInLibroFirma element in listElementSubscription) { if (string.IsNullOrEmpty(element.InfoDocumento.IdDocumentoPrincipale)) { doc = new Documento() { descrizione = element.InfoDocumento.Oggetto, docNumber = element.InfoDocumento.Docnumber, versionId = element.InfoDocumento.VersionId, version = element.InfoDocumento.NumVersione.ToString(), versionLabel = element.InfoDocumento.NumAllegato.ToString(), tipoFirma = element.TipoFirmaFile, inLibroFirma = true }; fileReqToSign.Add(doc as FileRequest); } else { attach = new Allegato() { descrizione = element.InfoDocumento.Oggetto, docNumber = element.InfoDocumento.Docnumber, versionId = element.InfoDocumento.VersionId, version = element.InfoDocumento.NumVersione.ToString(), versionLabel = element.InfoDocumento.NumAllegato.ToString(), tipoFirma = element.TipoFirmaFile, inLibroFirma = true }; fileReqToSign.Add(attach as FileRequest); } } bool isAdvancementProcess = false; List <FirmaResult> firmaResult = LibroFirmaManager.PutElectronicSignatureMassive(fileReqToSign, isAdvancementProcess); if (firmaResult != null) { foreach (FirmaResult r in firmaResult) { if (string.IsNullOrEmpty(r.errore)) { result = MassiveOperationReport.MassiveOperationResultEnum.OK; details = "Sottoscrizione avvenuta con successo"; oggetto = r.fileRequest.descrizione; ReportSignatureSelected.AddReportRow( oggetto, result, details); ListIdDocumentSigned.Add(r.fileRequest.docNumber); } else { result = MassiveOperationReport.MassiveOperationResultEnum.KO; oggetto = r.fileRequest.descrizione; details = String.Format( "Si sono verificati degli errori durante la procedura di sottoscrizione. {0}", r.errore); ReportSignatureSelected.AddReportRow( oggetto, result, details); } } } } #endregion #region DIGITALE ListCheck = new Dictionary <String, String>(); ListToSign = new Dictionary <string, FileToSign>(); //FIRMA PADES fileReqToSign.Clear(); List <ElementoInLibroFirma> listElementSignPADES = (from i in this.ListaElementiLibroFirma where i.TipoFirma.Equals(LibroFirmaManager.TypeEvent.SIGN_PADES) && i.StatoFirma.Equals(TipoStatoElemento.DA_FIRMARE) select i).ToList(); string idDocumento = null; string fileExstention = "PDF"; FileToSign file = null; String isFirmato = null; String signType = null; if (listElementSignPADES != null && listElementSignPADES.Count > 0) { noDigitalSign = false; foreach (ElementoInLibroFirma element in listElementSignPADES) { idDocumento = "P" + element.InfoDocumento.Docnumber; ListCheck.Add(idDocumento, idDocumento); isFirmato = element != null ? element.FileOriginaleFirmato : "0"; signType = element != null ? element.TipoFirmaFile : TipoFirma.NESSUNA_FIRMA; if (this.ListToSign != null) { if (!this.ListToSign.ContainsKey(idDocumento)) { file = new FileToSign(fileExstention, isFirmato, signType); this.ListToSign.Add(idDocumento, file); } else { file = this.ListToSign[idDocumento]; file.signed = isFirmato; file.fileExtension = fileExstention; } } } } //FIRMA CADES fileReqToSign.Clear(); List <ElementoInLibroFirma> listElementSignCADES = (from i in this.ListaElementiLibroFirma where i.TipoFirma.Equals(LibroFirmaManager.TypeEvent.SIGN_CADES) && i.StatoFirma.Equals(TipoStatoElemento.DA_FIRMARE) select i).ToList(); if (listElementSignCADES != null && listElementSignCADES.Count > 0) { noDigitalSign = false; foreach (ElementoInLibroFirma element in listElementSignCADES) { idDocumento = "C" + element.InfoDocumento.Docnumber; ListCheck.Add(idDocumento, idDocumento); isFirmato = element != null ? element.FileOriginaleFirmato : "0"; signType = element != null ? element.TipoFirmaFile : TipoFirma.NESSUNA_FIRMA; if (this.ListToSign != null) { if (!this.ListToSign.ContainsKey(idDocumento)) { isFirmato = element != null ? element.FileOriginaleFirmato : "0"; file = new FileToSign(fileExstention, isFirmato, signType); this.ListToSign.Add(idDocumento, file); } else { file = this.ListToSign[idDocumento]; file.signed = isFirmato; file.fileExtension = fileExstention; file.signType = signType; } } } } #endregion if (noDigitalSign) { DigitalSignatureSelectedItem(); } else { switch (tipoSupportoFirma) { case "H": HttpContext.Current.Session["CommandType"] = null; popupCall = "ajaxModalPopupMassiveSignatureHSM();"; break; case "L": componentType = UserManager.getComponentType(Request.UserAgent); if (componentType == Constans.TYPE_ACTIVEX || componentType == Constans.TYPE_SMARTCLIENT) { popupCall = "ajaxModalPopupMassiveDigitalSignature();"; } else if (componentType == Constans.TYPE_APPLET) { HttpContext.Current.Session["CommandType"] = null; popupCall = "ajaxModalPopupMassiveDigitalSignatureApplet();"; } else if (componentType == Constans.TYPE_SOCKET) { HttpContext.Current.Session["CommandType"] = null; popupCall = "ajaxModalPopupMassiveDigitalSignatureSocket();"; } break; } ScriptManager.RegisterStartupScript(this, this.GetType(), "MassiveSignatureHSM", popupCall, true); } } catch (System.Exception ex) { UIManager.AdministrationManager.DiagnosticError(ex); return; } }