/// <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); }
public static bool AddVersion(DocsPaVO.documento.FileRequest fileRequest, bool daInviare, InfoUtente infoUtente) { bool result = true; bool update = false; string oldApp = null; System.Data.DataSet ds; DocsPaDB.Query_DocsPAWS.Documenti doc = new DocsPaDB.Query_DocsPAWS.Documenti(); try { if (fileRequest.applicazione != null) { if (fileRequest.applicazione.systemId == null) { logger.Debug("sysid vuoto"); DocsPaVO.documento.Applicazione res = new DocsPaVO.documento.Applicazione(); doc.GetExt(fileRequest.applicazione.estensione, ref res); fileRequest.applicazione = res; } logger.Debug("Update della tabella profile"); string param = "(APPLICATION is NULL OR APPLICATION != " + fileRequest.applicazione.systemId + ") AND DOCNUMBER=" + fileRequest.docNumber; doc.GetApplication(out oldApp, fileRequest.docNumber, fileRequest.applicazione.systemId, param); update = true; } DocsPaDB.Query_DocsPAWS.Documentale documentale = new DocsPaDB.Query_DocsPAWS.Documentale(); documentale.AddVersion(ref fileRequest, infoUtente.idPeople, infoUtente.userId); //ESTRAZIONE DEL FILENAME, VERSION, LASTEDITTIME doc.SetCompVersions(fileRequest.versionId, fileRequest.docNumber, out ds); fileRequest.fileName = ds.Tables["VERS"].Rows[0]["PATH"].ToString(); fileRequest.version = ds.Tables["VERS"].Rows[0]["VERSION"].ToString(); fileRequest.subVersion = ds.Tables["VERS"].Rows[0]["SUBVERSION"].ToString(); fileRequest.versionLabel = ds.Tables["VERS"].Rows[0]["VERSION_LABEL"].ToString(); fileRequest.dataInserimento = ds.Tables["VERS"].Rows[0]["DTA_CREAZIONE"].ToString(); DocsPaDB.Query_DocsPAWS.Utenti u = new DocsPaDB.Query_DocsPAWS.Utenti(); string full_name_utente = u.getUtenteById(infoUtente.idPeople).descrizione; if (full_name_utente != null) { fileRequest.autore = full_name_utente; } //EMosca 29/11/2004 /*Aggiunto && oldApp!="" nell'if. * oldApp risulta vuoto per tutte le versioni * (tranne Hummingbird che inserisce di default un pdf di size=0 alla creazione del doc.) */ if (update && oldApp != "") { DocsPaDB.Query_DocsPAWS.Documenti documenti = new DocsPaDB.Query_DocsPAWS.Documenti(); documenti.UpdateApplication(oldApp, fileRequest.docNumber); } DocsPaDB.Query_DocsPAWS.Documenti documenti2 = new DocsPaDB.Query_DocsPAWS.Documenti(); documenti2.UpdateVersionManager(fileRequest, daInviare); logger.Debug("Fine addVersion"); } catch (Exception exception) { logger.Debug("Errore durante l'aggiunta di una versione.", exception); if (update) { DocsPaDB.Query_DocsPAWS.Documenti documenti = new DocsPaDB.Query_DocsPAWS.Documenti(); documenti.UpdateApplication(oldApp, fileRequest.docNumber); } result = false; } return(result); }