/// <summary> /// Funzione per lo spostamento di fascicoli nell'area di lavoro /// </summary> /// <param name="projectsInformation">Lista dei fascicoli da spostare</param> /// <param name="report">Report dell'esecuzione</param> private void MoveDocumentsInWorkingAreaRole(List <Fascicolo> projectsInformation, MassiveOperationReport report) { // Per ogni fascicolo... foreach (Fascicolo prj in projectsInformation) { try { if (ProjectManager.isFascInADLRole(prj.systemID, this.Page) != 1) { // ...spostamento del fascicolo nell'area di lavoro ProjectManager.addFascicoloInAreaDiLavoroRole(prj, UserManager.GetInfoUser()); // ...aggiunta di un risultato positivo report.AddReportRow( prj.codice, MassiveOperationReport.MassiveOperationResultEnum.OK, "Fascicolo inserito correttamento nell'area di lavoro."); } else { report.AddReportRow( prj.codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Fascicolo già inserito nell'area di lavoro."); } } catch (Exception e) { report.AddReportRow( prj.codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Errore durante lo spostamento del fascicolo nell'area di lavoro."); } } }
/// <summary> /// Funzione per lo spostamento dei documenti nell'area di lavoro /// </summary> /// <param name="documentsInfo">L'elenco dei documenti da spostare</param> /// <param name="report">Report del''esecuzione</param> private void RemoveDocumentsFromWorkingAreaRole(List <MassiveOperationTarget> documentsIds, MassiveOperationReport report) { // Per ogni documento... foreach (MassiveOperationTarget mot in documentsIds) { // ...spostamento del documento nell'area di lavoro try { if (DocumentManager.isDocInADLRole(mot.Id, this) != 0) { DocumentManager.eliminaDaAreaLavoroRole(this, mot.Id, null); report.AddReportRow( mot.Codice, MassiveOperationReport.MassiveOperationResultEnum.OK, "Documento rimosso correttamente dall'area di lavoro."); } else { report.AddReportRow( mot.Id, MassiveOperationReport.MassiveOperationResultEnum.KO, "Documento già rimosso dall'area di lavoro."); } } catch (Exception e) { report.AddReportRow( mot.Codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Errore durante la rimozione del documento dall'area di lavoro. Dettagli: " + e.Message); } } }
/// <summary> /// Funzione per la rimozione dei fascicoli dall'area di lavoro /// </summary> /// <param name="projectsInformation">Lista dei fascicoli da rimuovere</param> /// <param name="report">Report dell'esecuzione</param> private void RemoveProjectsFromWorkingAreaRole(List <Fascicolo> projectsInformation, MassiveOperationReport report) { // Per ogni fascicolo... foreach (Fascicolo prj in projectsInformation) { try { if (ProjectManager.isFascInADLRole(prj.systemID, this) != 0) { // ...rimozione del fascicolo nell'area di lavoro ProjectManager.eliminaFascicoloDaAreaDiLavoroRole(prj, UserManager.GetInfoUser()); // ...aggiunta di un risultato positivo report.AddReportRow( prj.codice, MassiveOperationReport.MassiveOperationResultEnum.OK, "Fascicolo rimosso correttamento dall'area di lavoro."); } else { report.AddReportRow( prj.codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Fascicolo già rimosso dall'area di lavoro."); } } catch (Exception e) { report.AddReportRow( prj.codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Errore durante la rimozione del fascicolo dall'area di lavoro. Dettagli: " + e.Message); } } }
/// <summary> /// Funzione per lo spostamento dei documenti nell'area di lavoro /// </summary> /// <param name="documentsInfo">L'elenco dei documenti da spostare</param> /// <param name="report">Report del''esecuzione</param> private void MoveDocumentsInWorkingArea(List <InfoDocumento> documentsInfo, MassiveOperationReport report) { // Per ogni documento... foreach (InfoDocumento docInfo in documentsInfo) { string id = MassiveOperationUtils.getItem(docInfo.idProfile).Codice; // ...spostamento del documento nell'area di lavoro try { if (DocumentManager.isDocInADL(docInfo.idProfile, this.Page) == 0 && DocumentManager.isDocInADLRole(docInfo.idProfile, this.Page) == 0) { SchedaDocumento sd = DocumentManager.getDocumentDetails(this, docInfo.docNumber, docInfo.docNumber); DocumentManager.addAreaLavoro(this, sd); report.AddReportRow( id, MassiveOperationReport.MassiveOperationResultEnum.OK, "Documento inserito correttamente nell'area di lavoro."); } else { report.AddReportRow( id, MassiveOperationReport.MassiveOperationResultEnum.KO, "Documento già inserito nell'area di lavoro."); } } catch (Exception e) { report.AddReportRow( id, MassiveOperationReport.MassiveOperationResultEnum.KO, "Errore durante lo spostamento del documento nell'area di lavoro. Dettagli: " + e.Message); } } }
/// <summary> /// Funzione per la validazione dei dati sul documento e l'avvio dell'inserimento /// nell'area di conservazione /// </summary> /// <param name="documentDetails">Dettagli del documento da inserire nell'area di conservazione</param> /// <param name="report">Report dello spostamento</param> private void CheckDataValidityAndInsertInSA(SchedaDocumento documentDetails, MassiveOperationReport report) { // Identificativo dell'istanza di certificazione String conservationAreaId; // Se il documento ha un file acquisito if (Convert.ToInt32(documentDetails.documenti[0].fileSize) > 0 && (string.IsNullOrEmpty(documentDetails.inConservazione) || !(documentDetails.inConservazione).Equals("1"))) { // Inserimento del documento in area di conservazione this.InsertInSA(documentDetails, report); } else { string codice = MassiveOperationUtils.getItem(documentDetails.systemId).Codice; if (!string.IsNullOrEmpty(documentDetails.inConservazione) && (documentDetails.inConservazione).Equals("1")) { report.AddReportRow( codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Il documento risulta già inserito in una nuova istanza di conservazione, impossibile inserirlo nuovamente"); } else { report.AddReportRow( codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Il documento principale non ha alcun file associato, impossibile inserirlo in area conservazione"); } } }
/// <summary> /// Funzione per l'inserimento di fascicoli nell'area di conservazione /// </summary> /// <param name="idProjects">ID dei fascicoli da inserire in area di conservazione</param> /// <param name="reportToCompile">Report da compilare</param> /// <returns>Report di inserimento</returns> public void ExecuteInsertProjectsInSA(List <MassiveOperationTarget> idProjects, MassiveOperationReport reportToCompile) { string idIstanza = DocumentManager.getPrimaIstanzaAreaCons(this, UserManager.getInfoUtente(Page).idPeople, UserManager.getInfoUtente(Page).idGruppo); ItemsConservazione[] itemsCons = null; if (!string.IsNullOrEmpty(idIstanza)) { itemsCons = DocumentManager.getItemsConservazioneLite(idIstanza, this, UserManager.getInfoUtente()); } // Per ogni id di fascicolo foreach (MassiveOperationTarget mot in idProjects) { // Recupero dei system id dei documenti presenti // all'interno del fascicolo // SearchResultInfo[] idDocuments = FascicoliManager.getDocumentiFromFascicolo(mot.Id); // Lista dei system id dei documenti contenuti nel fasciolo string[] idDocuments = FascicoliManager.getIdDocumentiFromFascicolo(mot.Id); List <MassiveOperationTarget> temp = new List <MassiveOperationTarget>(); for (int i = 0; i < idDocuments.Length; i++) { temp.Add(new MassiveOperationTarget(idDocuments[i], idDocuments[i])); // Inserimento dei documenti in area di conservazione // Identificativo dell'istanza di certificazione String conservationAreaId; // Se il documento ha un file acquisito SchedaDocumento documentDetails = DocumentManager.getDettaglioDocumento(this.Page, idDocuments[i], idDocuments[i]); if (Convert.ToInt32(documentDetails.documenti[0].fileSize) > 0) { // Inserimento del documento in area di conservazione //Inserimento del metodo di controllo della presenza di un documento fascicolato nell'istanza if (this.CheckProjectAndInsertInSA(documentDetails.systemId, mot.Id, itemsCons)) { this.InsertInSA2(documentDetails, reportToCompile, mot.Id); } else { string codice = documentDetails.systemId; // Altrimenti viene aggiunto un risultato negativo reportToCompile.AddReportRow( codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Il documento interno al fascicolo è già presente in una nuova istanza in area conservazione, impossibile inserirlo nuovamente"); } } else { string codice = documentDetails.systemId; // Altrimenti viene aggiunto un risultato negativo reportToCompile.AddReportRow( codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Il documento principale non ha alcun file associato, impossibile inserirlo in area conservazione"); } } } }
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; }
/// <summary> /// Visualizzazione dell'esito della firma applicata ad uno o più documenti /// </summary> protected void ShowReport() { List <FirmaDigitaleResultStatus> res = FirmaDigitaleResultManager.CurrentData; MassiveOperationReport report = new MassiveOperationReport(); foreach (FirmaDigitaleResultStatus temp in res) { MassiveOperationTarget target = MassiveOperationUtils.getItem(temp.IdDocument); MassiveOperationReport.MassiveOperationResultEnum result = MassiveOperationReport.MassiveOperationResultEnum.OK; if (!temp.Status) { result = MassiveOperationReport.MassiveOperationResultEnum.KO; } report.AddReportRow(target.Codice, result, temp.StatusDescription); } if (!IsLF) { string[] pars = new string[] { "" + report.Worked, "" + report.NotWorked }; report.AddSummaryRow("Documenti lavorati: {0} - Documenti non lavorati: {1}", pars); this.generateReport(report, "Firma digitale massiva"); } else { HttpContext.Current.Session["massiveSignReport"] = report; } //PDZ 17/01/2017 //Spostata da dentro if (!IsLF) FirmaDigitaleResultManager.ClearData(); }
/// <summary> /// Funzione per il recupero delle informazioni sui fascicoli da spostare in ADL /// </summary> /// <param name="projectsId">Lista degli identificativi dei fascicoli</param> /// <param name="report">Report dell'esecuzione</param> /// <returns>Lista delle informazioni sui fascicoli</returns> private List <Fascicolo> LoadProjectInformation(List <MassiveOperationTarget> projectsId, MassiveOperationReport report) { // Lista da restituire List <Fascicolo> toReturn = new List <Fascicolo>(); // Per ogni fascicolo... foreach (MassiveOperationTarget mot in projectsId) { try { // ...aggiunta del fascicolo alla lista dei fascicoli toReturn.Add(ProjectManager.getFascicolo( this, mot.Id)); } catch (Exception e) { report.AddReportRow( mot.Codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Errore durante il reperimento delle informazioni sul fascicolo."); } } // Restituzione della lista con le informaizoni sui fascicoli return(toReturn); }
/// <summary> /// Visualizzazione dell'esito della firma applicata ad uno o più documenti /// </summary> protected void ShowReport() { List <FirmaResult> firmaResult = new List <FirmaResult>(); List <FirmaDigitaleResultStatus> res = FirmaDigitaleResultManager.CurrentData; MassiveOperationReport report = new MassiveOperationReport(); foreach (FirmaDigitaleResultStatus temp in res) { MassiveOperationTarget target = MassiveOperationUtils.getItem(temp.IdDocument); MassiveOperationReport.MassiveOperationResultEnum result = MassiveOperationReport.MassiveOperationResultEnum.OK; if (target == null) { result = MassiveOperationReport.MassiveOperationResultEnum.KO; report.AddReportRow(temp.IdDocument, result, temp.StatusDescription); } else { if (!temp.Status) { result = MassiveOperationReport.MassiveOperationResultEnum.KO; } report.AddReportRow(target.Codice, result, temp.StatusDescription); } FirmaResult firmaTerminata = new FirmaResult(); firmaTerminata.fileRequest = new FileRequest(); //firmaTerminata.fileRequest. } if (!IsLF) { string[] pars = new string[] { "" + report.Worked, "" + report.NotWorked }; report.AddSummaryRow("Documenti lavorati: {0} - Documenti non lavorati: {1}", pars); this.generateReport(report, "Firma digitale massiva"); FirmaDigitaleResultManager.ClearData(); } else { HttpContext.Current.Session["massiveSignReport"] = report; FirmaDigitaleResultManager.ClearData(); } }
/// <summary> /// Al click sul pulsante bisogna creare il documento per l'inoltro massivo /// </summary> protected override bool btnConferma_Click(object sender, EventArgs e) { #region Dichiarazione variabili // 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; #endregion // Recupero della lista dei system id dei documenti selezionati selectedItem = MassiveOperationUtils.GetSelectedItems(); // Generazione della scheda MassiveOperationReport report = new MassiveOperationReport(); try { 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"); this.addJSOnChiudiButton("self.returnValue=true;self.close();"); return(true); }
private void InsertRow(string result, MassiveOperationReport report, string codice) { switch (result) { case "OK": report.AddReportRow(codice, MassiveOperationReport.MassiveOperationResultEnum.OK, "Documento inserito correttamente nella coda di versamento."); break; case "IN_QUEUE": report.AddReportRow(codice, MassiveOperationReport.MassiveOperationResultEnum.AlreadyWorked, "Il documento è già in attesa di versamento."); break; case "DOC_CONS": report.AddReportRow(codice, MassiveOperationReport.MassiveOperationResultEnum.AlreadyWorked, "Il documento è già stato preso in carico dal sistema di conservazione."); break; case "INS_ERR": report.AddReportRow(codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Errore durante l'inserimento nella coda di versamento"); break; case "CONS_ERR": report.AddReportRow(codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Non è stato possibile consolidare il documento."); break; case "STATE_ERR": report.AddReportRow(codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Non è stato possibile reperire lo stato di conservazione del documento."); break; } }
private MassiveOperationReport ProceedWithOperation(List <MassiveOperationTarget> selectedItem, RemoveVersionType type) { // Inizializzazione del report MassiveOperationReport report = new MassiveOperationReport(); List <ImportResult> res = DocumentManager.RimuoviVersioniMassivo(selectedItem, type, this); foreach (ImportResult temp in res) { string codice = MassiveOperationUtils.getItem(temp.IdProfile).Codice; report.AddReportRow(codice, (temp.Outcome == OutcomeEnumeration.OK) ? MassiveOperationReport.MassiveOperationResultEnum.OK : MassiveOperationReport.MassiveOperationResultEnum.KO, temp.Message); } return(report); }
/// <summary> /// Funzione per la rimozione dei fascicoli dall'area di lavoro /// </summary> /// <param name="projectsInformation">Lista dei fascicoli da rimuovere</param> /// <param name="report">Report dell'esecuzione</param> private void RemoveProjectsFromWorkingArea(List <Fascicolo> projectsInformation, MassiveOperationReport report) { // Per ogni fascicolo... foreach (Fascicolo prj in projectsInformation) { try { if (!prj.InAreaLavoro.Equals("0")) { // ...rimozione del fascicolo nell'area di lavoro FascicoliManager.eliminaFascicoloDaAreaDiLavoro( this, prj); // ...aggiunta di un risultato positivo report.AddReportRow( prj.codice, MassiveOperationReport.MassiveOperationResultEnum.OK, "Fascicolo rimosso correttamento dall'area di lavoro."); } else { report.AddReportRow( prj.codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Fascicolo già rimosso dall'area di lavoro."); } } catch (Exception e) { report.AddReportRow( prj.codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Errore durante la rimozione del fascicolo dall'area di lavoro. Dettagli: " + e.Message); } } }
/// <summary> /// Funzione per lo spostamento di fascicoli nell'area di lavoro /// </summary> /// <param name="projectsInformation">Lista dei fascicoli da spostare</param> /// <param name="report">Report dell'esecuzione</param> private void MoveDocumentsInWorkingArea(List <Fascicolo> projectsInformation, MassiveOperationReport report) { // Per ogni fascicolo... foreach (Fascicolo prj in projectsInformation) { try { if (!prj.InAreaLavoro.Equals("1")) { // ...spostamento del fascicolo nell'area di lavoro FascicoliManager.addFascicoloInAreaDiLavoro( this, prj); // ...aggiunta di un risultato positivo report.AddReportRow( prj.codice, MassiveOperationReport.MassiveOperationResultEnum.OK, "Fascicolo inserito correttamento nell'area di lavoro."); } else { report.AddReportRow( prj.codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Fascicolo già inserito nell'area di lavoro."); } } catch (Exception e) { report.AddReportRow( prj.codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Errore durante lo spostamento del fascicolo nell'area di lavoro."); } } }
/// <summary> /// Questa funzione si occupa di avviare lo spostamento nell'area di conservazione /// </summary> /// <param name="documentsId">Lista dei system id dei documenti selezionati</param> /// <returns>Report dell'inserimento</returns> private void ExecuteInsertDocumentsInSA(List <MassiveOperationTarget> documentsId, MassiveOperationReport reportToCompile) { // Per ogni id di documento foreach (MassiveOperationTarget mot in documentsId) { try { // Recupero della scheda documento SchedaDocumento documentDetails = DocumentManager.getDettaglioDocumento( this.Page, mot.Id, String.Empty); // Se c'è la scheda documento, si procede con la verifica dei dati e con // l'eventuale inserimento nell'area di conservazione if (documentDetails != null) { this.CheckDataValidityAndInsertInSA(documentDetails, reportToCompile); } else { // Altrimenti viene inserito un risultato negativo reportToCompile.AddReportRow( mot.Codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Non è stato possibile recuperare il dettaglio sul documento."); } } catch (Exception e) { reportToCompile.AddReportRow( mot.Codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Errore durante il recupero dei dettagli sul documento."); } } }
/// <summary> /// Funzione per il caricamento delle informaioni sui documenti /// </summary> /// <param name="documentSystemId">Lista dei system id dei documenti di cui recuperare le informazioni</param> /// <param name="report">Report dell'esecuzione</param> /// <returns>Lista delle informazioni sui documenti</returns> private List <InfoDocumento> LoadDocumentInformation(List <MassiveOperationTarget> documentSystemId, MassiveOperationReport report) { // L'oggetto da restituire List <InfoDocumento> toReturn = new List <InfoDocumento>(); // Oggetto con le informazioni di base sul documento BaseInfoDoc baseInfoDoc; // Recupero delle informazioni sui documenti foreach (MassiveOperationTarget mot in documentSystemId) { try { // Recupero delle informazioni di base sul documento baseInfoDoc = DocumentManager.GetBaseInfoForDocument( mot.Id, String.Empty, String.Empty).Where(e => e.IdProfile.Equals(mot.Id)).FirstOrDefault(); // Recuper dell'oggetto info documento toReturn.Add(DocumentManager.GetInfoDocumento( baseInfoDoc.IdProfile, baseInfoDoc.DocNumber, this)); } catch (Exception e) { report.AddReportRow( mot.Codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Errore durante il recupero delle informazioni sul documento."); } } // Restiutuzione della lista delle informazioni sui documento da spostare nell'ADL return(toReturn); }
/// <summary> /// Funzione per la fascicolazione dei documenti /// </summary> /// <param name="selectedItem">Lista dei system id dei documenti selezionati</param> /// <param name="project">Il fascicolo su cui fascicolare</param> /// <param name="reportTable">Tabella del report in cui inserire le informazioni sull'esito degli import</param> private void ProceedWithOperation(List <MassiveOperationTarget> selectedItem, Fascicolo project, MassiveOperationReport report) { // Un booleano utilizzato per indicare che un documento è già // fascicolato in un determinato fascicolo bool isAlreadyClassifficated; // Per indicare se il documento è bloccato bool isBlocked; // Il risultato della fascicolazione bool classificationResult; // Il messaggio da agigungere al report string message; bool isAnnullato; // Il risultato da aggiungere al report MassiveOperationReport.MassiveOperationResultEnum result; DocsPaWebService ws = new DocsPaWebService(); // Per ogni documento da fascicolare... foreach (MassiveOperationTarget mot in selectedItem) { // Inizializzazione di messaggio e risultato message = String.Empty; result = MassiveOperationReport.MassiveOperationResultEnum.OK; InfoUtente infoUtente = UserManager.getInfoUtente(this); // ... si verifica se il documento è già fascicolato nel fascicolo // selezionato //isAlreadyClassifficated = DocumentManager.IsDocumentInProject(this, mot.Id, project.systemID); isAlreadyClassifficated = DocumentManager.IsDocumentInFolderOrSubFolder(this, infoUtente, mot.Id, project); //Verifico se il documento è in checkout isBlocked = DocsPAWA.CheckInOut.CheckInOutServices.IsCheckedOutDocument(mot.Id, mot.Id, infoUtente, true); isAnnullato = ws.IsDocAnnullatoByIdProfile(mot.Id); string accessRight = ws.getAccessRightDocBySystemID(mot.Id, infoUtente); // ...se il documento è già fascicolato, viene aggiunto un messaggio // adeguato al report if (isAlreadyClassifficated) { message = "Il documento risulta già fascicolato nel fascicolo specificato o non è stato possibile recuperare informazioni sui fascicoli."; result = MassiveOperationReport.MassiveOperationResultEnum.AlreadyWorked; } else if (isBlocked) { message = "Il documento risulta bloccato."; result = MassiveOperationReport.MassiveOperationResultEnum.KO; } else if (accessRight.Equals("20")) { result = MassiveOperationReport.MassiveOperationResultEnum.KO; message = String.Format("Il documento è in attesa di accettazione, quindi non può essere fascicolato"); } else if (isAnnullato) { result = MassiveOperationReport.MassiveOperationResultEnum.KO; message = String.Format("Il documento risulta annullato, quindi non può essere fascicolato"); } else { // ...altrimenti si procede con la classificazione classificationResult = DocumentManager.FascicolaDocumentoAM( this, mot.Id, project, out message); // Impostazione di un messaggio adeguato in base all'esito della // fascicolazione if (classificationResult) { message = "Documento fascicolato con successo."; } else { result = MassiveOperationReport.MassiveOperationResultEnum.KO; message = "Errore durante la fascicolazione del documento."; } } // Aggiunta della riga al report report.AddReportRow(mot.Codice, result, message); } }
/// <summary> /// Event Handler per il click del pulsante conferma /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected override bool btnConferma_Click(object sender, EventArgs e) { // Il report da mostrare all'utente MassiveOperationReport report; // Lista di system id degli elementi selezionati List <MassiveOperationTarget> selectedItem; // Il fascicolo selezionato per la fascicolazione rapida Fascicolo project; // Valore utilizzato per indicare che è possibile procedere con la fascicolazione bool canProceed = true; // Inizializzazione del report report = new MassiveOperationReport(); // Il messaggio di errore StringBuilder errorMessage = new StringBuilder("Impossibile eseguire la fascicolazione:"); // Recupero della lista dei system id dei documenti selezionati selectedItem = MassiveOperationUtils.GetSelectedItems(); // Recupero del fascicolo selezionato per la fascicolazione rapida project = FascicoliManager.getFascicoloSelezionatoFascRapida(this); // Se il fascicolo non è valorizzato non si può procedere if (project == null) { canProceed = false; errorMessage.AppendLine(" Selezionare un fascicolo in cui fascicolare."); } // Se non sono stati selezionati documenti, non si può procedere con la fascicolazione if (selectedItem == null || selectedItem.Count == 0) { canProceed = false; errorMessage.AppendLine("- Selezionare almeno un documento da fascicolare."); } // Se non è possibile continuare, viene salvata una nuova riga per il report // e ne viene impostato l'esito negativo if (!canProceed) { report.AddReportRow( "N.A.", MassiveOperationReport.MassiveOperationResultEnum.KO, errorMessage.ToString()); } else { // Altrimenti si procede con la fascicolazione this.ProceedWithOperation(selectedItem, project, report); } string[] pars = new string[] { "" + report.Worked, "" + report.NotWorked }; report.AddSummaryRow("Documenti lavorati: {0} - Documenti non lavorati: {1}", pars); this.generateReport(report, "Fascicolazione massiva"); return(true); }
/// <summary> /// Funzione per l'inserimento di fascicoli nell'area di conservazione /// </summary> /// <param name="idProjects">ID dei fascicoli da inserire in area di conservazione</param> /// <param name="reportToCompile">Report da compilare</param> /// <returns>Report di inserimento</returns> public void ExecuteInsertProjectsInSA(List <MassiveOperationTarget> idProjects, MassiveOperationReport reportToCompile) { string idIstanza = DocumentManager.getPrimaIstanzaAreaCons(this, UserManager.GetInfoUser().idPeople, UserManager.GetInfoUser().idGruppo); ItemsConservazione[] itemsCons = null; if (!string.IsNullOrEmpty(idIstanza)) { itemsCons = DocumentManager.getItemsConservazioneLite(idIstanza, this, UserManager.GetInfoUser()); } // Per ogni id di fascicolo foreach (MassiveOperationTarget mot in idProjects) { // Recupero dei system id dei documenti presenti // all'interno del fascicolo // SearchResultInfo[] idDocuments = FascicoliManager.getDocumentiFromFascicolo(mot.Id); // Lista dei system id dei documenti contenuti nel fasciolo string[] idDocuments = ProjectManager.getIdDocumentiFromFascicolo(mot.Id); List <MassiveOperationTarget> temp = new List <MassiveOperationTarget>(); #region MEV CS 1.5 - F03_01 // Indice dell'elemento lavorato int indexOfCurrentDoc = 0; // Dimensione complessiva raggiunta int currentDimOfDocs = 0; // Get valori limiti per le istanze di conservazione int DimMaxInIstanza = 0; int numMaxDocInIstanza = 0; int TolleranzaPercentuale = 0; try { InfoUtente infoUt = UserManager.GetInfoUser(); DimMaxInIstanza = DocumentManager.getDimensioneMassimaIstanze(infoUt.idAmministrazione); numMaxDocInIstanza = DocumentManager.getNumeroDocMassimoIstanze(infoUt.idAmministrazione); TolleranzaPercentuale = DocumentManager.getPercentualeTolleranzaDinesioneIstanze(infoUt.idAmministrazione); } catch (Exception ex) { } #endregion for (int i = 0; i < idDocuments.Length; i++) { temp.Add(new MassiveOperationTarget(idDocuments[i], idDocuments[i])); // Inserimento dei documenti in area di conservazione // Identificativo dell'istanza di certificazione String conservationAreaId; // Se il documento ha un file acquisito SchedaDocumento documentDetails = DocumentManager.getDocumentDetails(this.Page, idDocuments[i], idDocuments[i]); if (Convert.ToInt32(documentDetails.documenti[0].fileSize) > 0) { // Inserimento del documento in area di conservazione //Inserimento del metodo di controllo della presenza di un documento fascicolato nell'istanza if (this.CheckProjectAndInsertInSA(documentDetails.systemId, mot.Id, itemsCons)) { // MEV CS 1.5 - F03_01 #region oldCode //this.InsertInSA2(documentDetails, reportToCompile, mot.Id); #endregion #region NewCode this.InsertInSA2_WithConstraint(documentDetails, reportToCompile, mot.Id, ref indexOfCurrentDoc, ref currentDimOfDocs, DimMaxInIstanza, numMaxDocInIstanza, TolleranzaPercentuale ); #endregion // End MEV } else { string codice = documentDetails.systemId; // Altrimenti viene aggiunto un risultato negativo reportToCompile.AddReportRow( codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Il documento interno al fascicolo è già presente in una nuova istanza in area conservazione, impossibile inserirlo nuovamente"); } } else { string codice = documentDetails.systemId; // Altrimenti viene aggiunto un risultato negativo reportToCompile.AddReportRow( codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Il documento principale non ha alcun file associato, impossibile inserirlo in area conservazione"); } } } }
/// <summary> /// Questa funzione si occupa di avviare lo spostamento nell'area di conservazione /// </summary> /// <param name="documentsId">Lista dei system id dei documenti selezionati</param> /// <returns>Report dell'inserimento</returns> private void ExecuteInsertDocumentsInSA(List <MassiveOperationTarget> documentsId, MassiveOperationReport reportToCompile) { #region MEV CS 1.5 - F03_01 // Indice dell'elemento lavorato int indexOfCurrentDoc = 0; // Dimensione complessiva raggiunta int currentDimOfDocs = 0; // Get valori limiti per le istanze di conservazione int DimMaxInIstanza = 0; int numMaxDocInIstanza = 0; int TolleranzaPercentuale = 0; try { InfoUtente infoUt = UserManager.GetInfoUser(); DimMaxInIstanza = DocumentManager.getDimensioneMassimaIstanze(infoUt.idAmministrazione); numMaxDocInIstanza = DocumentManager.getNumeroDocMassimoIstanze(infoUt.idAmministrazione); TolleranzaPercentuale = DocumentManager.getPercentualeTolleranzaDinesioneIstanze(infoUt.idAmministrazione); } catch (Exception ex) { } #endregion // Per ogni id di documento foreach (MassiveOperationTarget mot in documentsId) { try { // Recupero della scheda documento SchedaDocumento documentDetails = DocumentManager.getDocumentDetails( this.Page, mot.Id, String.Empty); // Se c'è la scheda documento, si procede con la verifica dei dati e con // l'eventuale inserimento nell'area di conservazione if (documentDetails != null) { // MEV CS 1.5 - F03_01 #region OldCode //this.CheckDataValidityAndInsertInSA(documentDetails, reportToCompile); #endregion #region NewCode this.CheckDataValidityAndInsertInSA_WithConstraint(documentDetails, reportToCompile, ref indexOfCurrentDoc, ref currentDimOfDocs, DimMaxInIstanza, numMaxDocInIstanza, TolleranzaPercentuale ); #endregion // End MEV } else { // Altrimenti viene inserito un risultato negativo reportToCompile.AddReportRow( mot.Codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Non è stato possibile recuperare il dettaglio sul documento."); } } catch (Exception e) { reportToCompile.AddReportRow( mot.Codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Errore durante il recupero dei dettagli sul documento."); } } }
/// <summary> /// Funzione per l'inserimento di un documento nell'area di conservazione /// </summary> /// <param name="documentDetails">Dettagli del documento da inserire</param> /// <param name="report">Report di inserimento</param> private void InsertInSA_WithConstraint(SchedaDocumento documentDetails, MassiveOperationReport report, ref int indexOfCurrentDoc, ref int currentDimOfDocs, int DimMaxInIstanza, int numMaxDocInIstanza, int percentualeTolleranza ) { StringBuilder message = new StringBuilder(); String conservationAreaId; string id = MassiveOperationUtils.getItem(documentDetails.systemId).Codice; // Se si sta creando la prima istanza di conservazione... if (DocumentManager.isPrimaConservazione( UserManager.GetInfoUser().idPeople, UserManager.GetInfoUser().idGruppo) == 1) { message.Append("Si sta creando la prima istanza di conservazione. "); } // Recupero dell'eventiale fascicolo selezionato Fascicolo selectedProject = ProjectManager.getProjectInSession(); // Controllo Rispetto dei Vincoli dell'istanza #region Vincoli Istanza di Conservazione // Variabili di controllo per violazione dei vincoli sulle istanze bool numDocIstanzaViolato = false; bool dimIstanzaViolato = false; int TotalSelectedDocumentSize = 0; TotalSelectedDocumentSize = DocumentManager.GetTotalDocumentSize(documentDetails); // Dimensione documenti raggiunta currentDimOfDocs = TotalSelectedDocumentSize + currentDimOfDocs; // Numero di documenti raggiunti indexOfCurrentDoc = indexOfCurrentDoc + 1; numDocIstanzaViolato = DocumentManager.isVincoloNumeroDocumentiIstanzaViolato(indexOfCurrentDoc, numMaxDocInIstanza); dimIstanzaViolato = DocumentManager.isVincoloDimensioneIstanzaViolato(currentDimOfDocs, DimMaxInIstanza, percentualeTolleranza); double DimensioneMassimaConsentitaPerIstanza = 0; DimensioneMassimaConsentitaPerIstanza = DimMaxInIstanza - ((DimMaxInIstanza * percentualeTolleranza) / 100); int DimMaxConsentita = 0; DimMaxConsentita = Convert.ToInt32(DimensioneMassimaConsentitaPerIstanza); if (numDocIstanzaViolato || dimIstanzaViolato) { // Azzero le due variabili currentDimOfDocs = 0; indexOfCurrentDoc = 0; } #endregion // Inserimento del documento nella conservazione e recupero dell'id dell'istanza if (selectedProject != null) { // Da ricerca documenti in fascicolo conservationAreaId = DocumentManager.addAreaConservazioneAM_WithConstraint( this.Page, documentDetails.systemId, selectedProject.systemID, documentDetails.docNumber, UserManager.GetInfoUser(), "F", numDocIstanzaViolato, dimIstanzaViolato, DimMaxConsentita, numMaxDocInIstanza, TotalSelectedDocumentSize ); } else { conservationAreaId = DocumentManager.addAreaConservazioneAM_WithConstraint( this.Page, documentDetails.systemId, "", documentDetails.docNumber, UserManager.GetInfoUser(), "D", numDocIstanzaViolato, dimIstanzaViolato, DimMaxConsentita, numMaxDocInIstanza, TotalSelectedDocumentSize ); } try { if (conservationAreaId.ToString() != "-1") { int size_xml = DocumentManager.getItemSize( documentDetails, conservationAreaId); int doc_size = Convert.ToInt32(documentDetails.documenti[0].fileSize); int numeroAllegati = documentDetails.allegati.Length; string fileName = documentDetails.documenti[0].fileName; string tipoFile = Path.GetExtension(fileName); int size_allegati = 0; for (int i = 0; i < documentDetails.allegati.Length; i++) { size_allegati = size_allegati + Convert.ToInt32(documentDetails.allegati[i].fileSize); } int total_size = size_allegati + doc_size + size_xml; DocumentManager.insertSizeInItemCons(conservationAreaId, total_size); DocumentManager.updateItemsConservazione( tipoFile, Convert.ToString(numeroAllegati), conservationAreaId); } } catch (Exception e) { report.AddReportRow( id, MassiveOperationReport.MassiveOperationResultEnum.KO, "Si è verificato un errore durante l'inserimento del documento nell'area di conservazione"); } #region old code //report.AddReportRow( // id, // MassiveOperationReport.MassiveOperationResultEnum.OK, // "Documento inserito correttamente in area di conservazione."); #endregion #region MEV CS 1.5 - F03_01 if (!string.IsNullOrEmpty(conservationAreaId.ToString())) { report.AddReportRow( documentDetails.systemId, MassiveOperationReport.MassiveOperationResultEnum.OK, "Documento inserito correttamente in area di conservazione."); } else { report.AddReportRow( documentDetails.systemId, MassiveOperationReport.MassiveOperationResultEnum.KO, "Documento non inserito in area di conservazione per violazione vincoli dimensione istanza."); } #endregion }
private void ExecuteVersamento(List <MassiveOperationTarget> documentsId, MassiveOperationReport report) { foreach (MassiveOperationTarget target in documentsId) { try { // Recupero della scheda documento SchedaDocumento documentDetails = DocumentManager.getDocumentDetails(this.Page, target.Id, string.Empty); if (documentDetails != null) { if (documentDetails.documentoPrincipale != null) { report.AddReportRow(target.Codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Non è possibile versare allegati."); } else { if (this.isPredisposto(documentDetails)) { report.AddReportRow(target.Codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Non è possibile versare documenti predisposti."); } else { if (documentDetails.checkOutStatus != null && !string.IsNullOrEmpty(documentDetails.checkOutStatus.ID)) { report.AddReportRow(target.Codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Non è possibile versare documenti bloccati."); } else { if (this.checkRepertorio(documentDetails)) { report.AddReportRow(target.Codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Non è possibile versare repertori il cui contatore non sia scattato."); } else { if (documentDetails.documenti[0] != null) { if (!(string.IsNullOrEmpty(documentDetails.documenti[0].fileSize)) && Convert.ToInt32(documentDetails.documenti[0].fileSize) > 0) { string result = DocumentManager.AddDocToQueueCons(target.Id, UserManager.GetInfoUser()); this.InsertRow(result, report, target.Id); } else { report.AddReportRow(target.Codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Il documento principale non risulta essere stato acquisito."); } } else { report.AddReportRow(target.Codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Il documento principale non risulta essere stato acquisito."); } } } } } } else { report.AddReportRow(target.Codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Non è stato possibile recuperare il dettaglio sul documento."); } } catch (Exception ex) { report.AddReportRow(target.Codice, MassiveOperationReport.MassiveOperationResultEnum.KO, "Errore durante il recupero dei dettagli sul documento."); } } }
/// <summary> /// Funzione per l'applicazione del timestamp a tutti i documenti selezionati /// </summary> /// <param name="selectedItem">Lista dei system id dei documenti selezionati</param> /// <param name="report">Report di esecuzione</param> private void ApplyTimeStampToDocuments(List <MassiveOperationTarget> selectedItem, MassiveOperationReport report) { #region Dichiarazione variabili DocsPaWebService ws = new DocsPaWebService(); ws.Timeout = System.Threading.Timeout.Infinite; // Lista delle informazioni di base sul documento // contenete il file a cui aggiungere il timestamp BaseInfoDoc[] baseInfoDocs = null; // Le informazioni sul documento di interesse BaseInfoDoc tmpDoc; // Il file a cui applicare il timestamp string convertedFile; // Messaggio da aggiungere al report string message; // Risultato dell'applicazione del timestamp ad un documento MassiveOperationReport.MassiveOperationResultEnum result; #endregion // Per ogni documento a cui bisogna applicare il timestamp... foreach (MassiveOperationTarget temp in selectedItem) { // ...inizializzazione del messaggio e dell'esito message = String.Empty; result = MassiveOperationReport.MassiveOperationResultEnum.OK; string accessRight = ws.getAccessRightDocBySystemID(temp.Id, UserManager.getInfoUtente(this)); if (accessRight.Equals("20")) { message = "Il documento è in attesa di accettazione, quindi non può essere il effettuato Timestamp"; result = MassiveOperationReport.MassiveOperationResultEnum.KO; } // ...recupero del contenuto delle informazioni di base sul documento if (result == MassiveOperationReport.MassiveOperationResultEnum.OK) { try { if (accessRight.Equals("20")) { message = "Il documento è in attesa di accettazione, quindi non può essere il Timestamp"; result = MassiveOperationReport.MassiveOperationResultEnum.KO; } else { baseInfoDocs = DocumentManager.GetBaseInfoForDocument( temp.Id, String.Empty, String.Empty); } } catch (Exception e) { message = "Errore durante il recupero dei dati sul documento."; result = MassiveOperationReport.MassiveOperationResultEnum.KO; return; } // ...se baseInfoDocs non contiene elementi o non contiene un documento // con idProfile ugual a idProfile -> errore if (baseInfoDocs != null && baseInfoDocs.Where(e => e.IdProfile.Equals(temp.Id)).Count() == 1) { try { // Recupero delle informazioni sul documento tmpDoc = baseInfoDocs.Where(e => e.IdProfile.Equals(temp.Id)).FirstOrDefault(); // Recupero del contenuto del file a cui applicare il timestamp convertedFile = this.GetFileForDocument(tmpDoc); // Recupero del file e applicazione del time stamp message = this.ApplyTimeStampToDocument( convertedFile, tmpDoc.DocNumber, tmpDoc.VersionId); } catch (Exception e) { message = e.Message; result = MassiveOperationReport.MassiveOperationResultEnum.KO; } } else { message = "Errore durante il recupero dei dati sul documento."; result = MassiveOperationReport.MassiveOperationResultEnum.KO; } } // Aggiunta della riga al report report.AddReportRow( temp.Codice, result, message); } }
private bool PutHSMSign() { bool retVal = false; string errorMsg = string.Empty; if (!string.IsNullOrEmpty(this.TxtHsmAlias.Text) && !string.IsNullOrEmpty(this.TxtHsmDomain.Text) && !string.IsNullOrEmpty(this.TxtHsmPin.Text) && !string.IsNullOrEmpty(this.TxtHsmLitOtp.Text) && (this.HsmLitPades.Checked || this.HsmLitP7M.Checked)) { string alias = this.TxtHsmAlias.Text; string dominio = this.TxtHsmDomain.Text; string pin = this.TxtHsmPin.Text; string otp = this.TxtHsmLitOtp.Text; try { DigitalSignature.RemoteDigitalSignManager dsm = new DigitalSignature.RemoteDigitalSignManager(); DigitalSignature.RemoteDigitalSignManager.Memento m = new DigitalSignature.RemoteDigitalSignManager.Memento { Alias = alias, Dominio = dominio }; //Intanto salvo il memento dsm.HSM_SetMementoForUser(m); } catch (System.Exception ex) { return(true); } MassiveOperationReport.MassiveOperationResultEnum result; string codice = string.Empty; // Il dettaglio dell'elaborazione per un documento string details; MassiveOperationReport report = new MassiveOperationReport(); if ((IsLF || Continue) && HttpContext.Current.Session["massiveSignReport"] != null) { report = HttpContext.Current.Session["massiveSignReport"] as MassiveOperationReport; } //Lista dei fileReequest da passare in input al servizio di firma massiva List <FileRequest> fileRequestList = new List <FileRequest>(); //List<FileRequest> listFileReqLF = new List<FileRequest>(); this.FileTypes = UIManager.FileManager.GetSupportedFileTypes(Int32.Parse(UIManager.UserManager.GetInfoUser().idAmministrazione)); this.IsEnabledSupportedFileTypes = UIManager.FileManager.IsEnabledSupportedFileTypes(); string objType = Request.QueryString["objType"]; if (objType.Equals("D")) { this.SchedaDocumentList = this.LoadSchedaDocumentsList( MassiveOperationUtils.GetSelectedItems()); } // Invio della trasmissione per ogni documento da inviare foreach (SchedaDocumento schedaDoc in this.SchedaDocumentList) { result = MassiveOperationReport.MassiveOperationResultEnum.OK; details = String.Empty; // Verifica della possibilità di firmare il documento result = this.CanSignDocument(schedaDoc, out details); if (result != MassiveOperationReport.MassiveOperationResultEnum.KO) { fileRequestList.Add(schedaDoc.documenti[0]); } // Aggiunta di una riga al report if (result == MassiveOperationReport.MassiveOperationResultEnum.KO) { codice = MassiveOperationUtils.getItem(schedaDoc.docNumber).Codice; report.AddReportRow( codice, result, details); } } //PER TUTTI I DOCUMENTI CHE HANNO SUPERATO I CONTROLLI VADO AD APPLICARE LA FIRMA if (fileRequestList.Count > 0) { DigitalSignature.RemoteDigitalSignManager dsm = new DigitalSignature.RemoteDigitalSignManager(); bool cofirma = this.HsmRadioCoSign.Checked; //prendere dalla checkbox cofirma //ABBATANGELI - Hanno cambiato idea nuovamente e non è sempre cosign ma prende il valore dal checkbox cofirma ////ABBATANGELI - PITre richiede sempre la cofirma per hsm ////cofirma = true; bool timestamp = this.HsmCheckMarkTemporal.Checked; //prendere dalla checkbox timestamp DigitalSignature.RemoteDigitalSignManager.tipoFirma tipoFirma = new DigitalSignature.RemoteDigitalSignManager.tipoFirma(); if (this.HsmLitPades.Checked) { tipoFirma = DigitalSignature.RemoteDigitalSignManager.tipoFirma.PADES; } else { tipoFirma = DigitalSignature.RemoteDigitalSignManager.tipoFirma.CADES; cofirma = this.HsmRadioCoSign.Checked && !FirmaAnnidata; } List <FirmaResult> firmaResult = null; try { firmaResult = dsm.HSM_SignMultiSign(fileRequestList.ToArray(), cofirma, timestamp, tipoFirma, alias, dominio, otp, pin).ToList <FirmaResult>(); /*Commento perchè la distinzione tra documenti che devo firmare cades e quelli da firmare pades per il libro firma, la faccio prima, quando vado a selezionare SchedaDocumentList * if (!IsLF) * { * firmaResult = dsm.HSM_SignMultiSign(fileRequestList.ToArray(), cofirma, timestamp, tipoFirma, alias, dominio, otp, pin).ToList<FirmaResult>(); * } * else * { * List<MassiveOperationTarget> selectedItemSystemIdList = MassiveOperationUtils.GetSelectedItems(); * string typeSign = tipoFirma.Equals(DigitalSignature.RemoteDigitalSignManager.tipoFirma.CADES) ? "C" : "P"; * List<string> idDocumentList = (from temp in selectedItemSystemIdList where temp.Id.Contains(typeSign) select temp.Id.Replace(typeSign, "")).ToList<string>(); * listFileReqLF = (from f in fileRequestList where idDocumentList.Contains(f.docNumber) select f).ToList(); * if (listFileReqLF != null && listFileReqLF.Count > 0) * { * firmaResult = dsm.HSM_SignMultiSign(listFileReqLF.ToArray(), cofirma, timestamp, tipoFirma, alias, dominio, otp, pin).ToList<FirmaResult>(); * } * } */ if (firmaResult != null && ((firmaResult.Count > 1) || (firmaResult.Count == 1 && firmaResult[0].fileRequest != null))) { foreach (FirmaResult r in firmaResult) { string[] splitMsg = r.errore.Split(':'); if (splitMsg[0].Equals("true")) { result = MassiveOperationReport.MassiveOperationResultEnum.OK; details = "Firma HSM del documento avvenuta con successo"; codice = MassiveOperationUtils.getItem(r.fileRequest.docNumber).Codice; report.AddReportRow( codice, result, details); } else { if (r.esito == null || string.IsNullOrEmpty(r.esito.Codice)) { errorMsg = String.Format( "Si sono verificati degli errori durante la firma del documento. Dettagli: {0}", splitMsg[1]); } else { errorMsg = Utils.Languages.GetMessageFromCode(r.esito.Codice, UserManager.GetLanguageData()); } result = MassiveOperationReport.MassiveOperationResultEnum.KO; codice = MassiveOperationUtils.getItem(r.fileRequest.docNumber).Codice; details = errorMsg; report.AddReportRow( codice, result, details); } } } else { //List<FileRequest> list = IsLF ? listFileReqLF : fileRequestList; string error = "Si sono verificati degli errori durante la firma del documento"; if (firmaResult != null && firmaResult.Count > 0) { error += ": " + firmaResult[0].errore; } if (firmaResult[0].esito != null && !string.IsNullOrEmpty(firmaResult[0].esito.Codice)) { error = Utils.Languages.GetMessageFromCode(firmaResult[0].esito.Codice, UserManager.GetUserLanguage()); } foreach (FileRequest fr in fileRequestList) { result = MassiveOperationReport.MassiveOperationResultEnum.KO; codice = MassiveOperationUtils.getItem(fr.docNumber).Codice; details = error; report.AddReportRow( codice, result, details); } } } catch (Exception ex) { //List<FileRequest> list = IsLF ? listFileReqLF : fileRequestList; foreach (FileRequest fr in fileRequestList) { result = MassiveOperationReport.MassiveOperationResultEnum.KO; codice = MassiveOperationUtils.getItem(fr.docNumber).Codice; details = "Si sono verificati degli errori durante la firma HSM del documento."; report.AddReportRow( codice, result, details); } } } if (Continue) { HttpContext.Current.Session["massiveSignReport"] = report; //Se ho firmato CADES e ci sono documenti da firmare PADES non chiudo la maschera ma visualizzo un worning che //informa l'utente di inserire un nuovo otp per procedere con la firma this.TxtHsmLitOtp.Text = string.Empty; this.HsmLitP7M.Enabled = false; this.HsmLitPades.Enabled = false; this.HsmRadioCoSign.Enabled = false; this.UpOTP.Update(); this.UpPnlSign.Update(); ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.fra_main.ajaxDialogModal('WarningRequestNewOTPFirmaAnnidata', 'warning');} else {parent.ajaxDialogModal('WarningRequestNewOTPFirmaAnnidata', 'warning');}", true); return(false); } if (!IsLF) { // Introduzione della riga di summary string[] pars = new string[] { "" + report.Worked, "" + report.NotWorked }; report.AddSummaryRow("Documenti lavorati: {0} - Documenti non lavorati: {1}", pars); this.generateReport(report, "Firma HSM massiva"); } else { HttpContext.Current.Session["massiveSignReport"] = report; //Se ho firmato CADES e ci sono documenti da firmare PADES non chiudo la maschera ma visualizzo un worning che //informa l'utente di inserire un nuovo otp per procedere con la firma List <MassiveOperationTarget> selectedItemSystemIdList = MassiveOperationUtils.GetSelectedItems(); bool toSignPades = (from s in selectedItemSystemIdList where s.Id.Contains("P") select s).FirstOrDefault() != null; if (this.HsmLitP7M.Checked && toSignPades) { this.HsmLitP7M.Checked = false; this.HsmLitPades.Checked = true; this.TxtHsmLitOtp.Text = string.Empty; ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.fra_main.ajaxDialogModal('WarningRequestNewOTP', 'warning');} else {parent.ajaxDialogModal('WarningRequestNewOTP', 'warning');}", true); this.UpPnlSign.Update(); this.UpOTP.Update(); return(false); } } retVal = true; } else { retVal = false; ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.fra_main.ajaxDialogModal('WarningHsmSign', 'warning');} else {parent.ajaxDialogModal('WarningHsmSign', 'warning');}", true); } return(retVal); }
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; } }
/// <summary> /// Funzione per la conversione dei documenti in PDF /// </summary> /// <param name="documentsInfo">La lista con le informazioni sui documenti da convertire</param> /// <returns>Il report dell'elaborazione</returns> public MassiveOperationReport ConvertInPdf(List <BaseInfoDoc> documentsInfo) { DocsPaWebService ws = new DocsPaWebService(); ws.Timeout = System.Threading.Timeout.Infinite; // Il report da restituire MassiveOperationReport report; // Il risultato della messa in conversione di un documento MassiveOperationReport.MassiveOperationResultEnum tempResult; // Il messaggio da inserire nel report string message; // Informazioni sull'utente che ha lanciato la procedura InfoUtente userInfo; // Il file associato al documento byte[] content = null; // Inizializzazione del report report = new MassiveOperationReport(); // Recupero delle informazioni sull'utente userInfo = UserManager.getInfoUtente(this); foreach (BaseInfoDoc doc in documentsInfo) { // Inizializzazione del messaggio string codice = MassiveOperationUtils.getItem(doc.IdProfile).Codice; message = "Documento inserito correttamente nella coda di conversione PDF."; //Recupero i diritti sul documento string ar = ws.getAccessRightDocBySystemID(doc.IdProfile, UserManager.getInfoUtente(this)); // Verifica delle informazioni sul documento tempResult = this.ValidateDocumentInformation(doc, out message); if (ar.Equals("20")) { message = "Il documento è in attesa di accettazione, quindi non può essere convertito"; tempResult = MassiveOperationReport.MassiveOperationResultEnum.KO; } //Verifico che il documento non sia consolidato FirmaDigitale.FirmaDigitaleMng mng = new FirmaDigitale.FirmaDigitaleMng(); DocsPaWR.SchedaDocumento schedaDocumento = mng.GetSchedaDocumento(doc.DocNumber); if (schedaDocumento != null) { if (schedaDocumento.ConsolidationState != null && schedaDocumento.ConsolidationState.State > DocsPaWR.DocumentConsolidationStateEnum.None) { // Il documento risulta consolidato, non può essere firmato digitalmente message = "Il documento risulta consolidato"; tempResult = MassiveOperationReport.MassiveOperationResultEnum.KO; } } // Se il risultato di validazione delle informazioni è OK, si pruò procedere if (tempResult == MassiveOperationReport.MassiveOperationResultEnum.OK) { try { // Recupero delle informazioni sul file da convertire content = FileManager.getInstance(Session.SessionID).GetFile( this, doc.VersionId, doc.VersionNumber.ToString(), doc.DocNumber, doc.Path, doc.FileName, false).content; } catch (Exception e) { message = "Errore durante il reperimento del file associato al documento."; tempResult = MassiveOperationReport.MassiveOperationResultEnum.KO; } } // Se si può procedere si mette in coda il file da convertire if (tempResult == MassiveOperationReport.MassiveOperationResultEnum.OK) { try { // Avvio della conversione FileManager.EnqueueServerPdfConversionAM( this, userInfo, content, doc.FileName, new SchedaDocumento() { systemId = doc.IdProfile, docNumber = doc.DocNumber }); } catch (Exception e) { tempResult = MassiveOperationReport.MassiveOperationResultEnum.KO; message = "Errore durante l'inserimento del documento nella coda di conversione."; } } // Inserimento di una nuova riga nel report report.AddReportRow( codice, tempResult, message); } // Restituzione del report return(report); }
/// <summary> /// Funzione per l'inserimento di un documento nell'area di conservazione /// </summary> /// <param name="documentDetails">Dettagli del documento da inserire</param> /// <param name="report">Report di inserimento</param> private void InsertInSA2(SchedaDocumento documentDetails, MassiveOperationReport report, string idProject) { StringBuilder message = new StringBuilder(); String conservationAreaId; //string id = MassiveOperationUtils.getItem(documentDetails.systemId).Codice; // Se si sta creando la prima istanza di conservazione... if (DocumentManager.isPrimaConservazione( this, UserManager.getInfoUtente(Page).idPeople, UserManager.getInfoUtente(Page).idGruppo) == 1) { message.Append("Si sta creando la prima istanza di conservazione. "); } // Recupero dell'eventiale fascicolo selezionato Fascicolo selectedProject = FascicoliManager.getFascicoloSelezionato(); // Inserimento del documento nella conservazione e recupero dell'id dell'istanza if (!string.IsNullOrEmpty(idProject)) { // Da ricerca documenti in fascicolo conservationAreaId = DocumentManager.addAreaConservazioneAM( this.Page, documentDetails.systemId, idProject, documentDetails.docNumber, UserManager.getInfoUtente(Page), "F"); } else { conservationAreaId = DocumentManager.addAreaConservazioneAM( this.Page, documentDetails.systemId, "", documentDetails.docNumber, UserManager.getInfoUtente(Page), "D"); } try { int size_xml = DocumentManager.getItemSize( this.Page, documentDetails, conservationAreaId); int doc_size = Convert.ToInt32(documentDetails.documenti[0].fileSize); int numeroAllegati = documentDetails.allegati.Length; string fileName = documentDetails.documenti[0].fileName; string tipoFile = Path.GetExtension(fileName); int size_allegati = 0; for (int i = 0; i < documentDetails.allegati.Length; i++) { size_allegati = size_allegati + Convert.ToInt32(documentDetails.allegati[i].fileSize); } int total_size = size_allegati + doc_size + size_xml; DocumentManager.insertSizeInItemCons(Page, conservationAreaId, total_size); DocumentManager.updateItemsConservazione( this.Page, tipoFile, Convert.ToString(numeroAllegati), conservationAreaId); } catch (Exception e) { report.AddReportRow( documentDetails.systemId, MassiveOperationReport.MassiveOperationResultEnum.KO, "Si è verificato un errore durante l'inserimento del documento nell'area di conservazione"); } report.AddReportRow( documentDetails.systemId, MassiveOperationReport.MassiveOperationResultEnum.OK, "Documento inserito correttamente in area di conservazione."); }