/// <summary> /// Rimozione di una versione /// </summary> /// <param name="fileRequest"></param> /// <returns></returns> public bool RemoveVersion(DocsPaVO.documento.FileRequest fileRequest) { bool retValue = false; try { using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext()) { retValue = this.DocumentManagerETDOCS.RemoveVersion(fileRequest); if (retValue) { retValue = this.DocumentManagerDocumentum.RemoveVersion(fileRequest); } if (retValue) { transactionContext.Complete(); } } } catch (Exception ex) { string errorMessage = string.Format("Errore nella rimozione della versione: {0}", ex.Message); logger.Debug(errorMessage, ex); retValue = false; } return(retValue); }
/// <summary> /// Inserimento di una nuova versione /// </summary> /// <param name="fileRequest"></param> /// <param name="daInviare"></param> /// <returns></returns> public bool AddVersion(DocsPaVO.documento.FileRequest fileRequest, bool daInviare) { logger.Info("BEGIN"); bool retValue = false; try { using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext()) { retValue = this.DocumentManagerETDOCS.AddVersion(fileRequest, daInviare); if (retValue) { retValue = this.DocumentManagerDocumentum.AddVersion(fileRequest, daInviare); } if (retValue) { transactionContext.Complete(); } } } catch (Exception ex) { string errorMessage = string.Format("Errore nell'inserimento della versione: {0}", ex.Message); logger.Debug(errorMessage, ex); retValue = false; } logger.Info("END"); return(retValue); }
private File getFileDetail(DocsPaVO.documento.FileDocumento fileDoc, DocsPaVO.documento.FileRequest objFileRequest, DocsPaVO.utente.InfoUtente infoUtente) { string impronta; DocsPaDB.Query_DocsPAWS.Documenti doc = new DocsPaDB.Query_DocsPAWS.Documenti(); doc.GetImpronta(out impronta, objFileRequest.versionId, objFileRequest.docNumber); string algo = "N.A"; if (impronta == DocsPaUtils.Security.CryptographyManager.CalcolaImpronta256(fileDoc.content)) { algo = "SHA256"; } else if (impronta == DocsPaUtils.Security.CryptographyManager.CalcolaImpronta(fileDoc.content)) { algo = "SHA1"; } File F = new File { Impronta = impronta, Dimensione = objFileRequest.fileSize, Formato = fileDoc.contentType, AlgoritmoHash = algo, FirmaDigitale = extractFirmaDigitale(fileDoc), MarcaTemporale = extractMarcaTemporale(objFileRequest, infoUtente) }; return(F); }
private string SaveDocument(InfoUtente userInfo, Ruolo role, SchedaDocumento document, FileDocumento fileDoc, out Ruolo[] superiori) { //Salvataggio del documento DocsPaDocumentale.Documentale.DocumentManager docManager = new DocsPaDocumentale.Documentale.DocumentManager(userInfo); //Salvataggio dell'oggetto document = ProtoManager.addOggettoLocked(userInfo.idAmministrazione, document); Ruolo[] ruoliSuperiori; //if (docManager.CreateDocumentoStampaRegistro(document, role, out ruoliSuperiori)) if (docManager.CreateDocumentoGrigio(document, role, out ruoliSuperiori)) //if(docManager.CreateDocumentoGrigio(document, role)) { //Notifica evento documento creato //DocsPaDocumentale.Interfaces.IAclEventListener eventsNotification = new DocsPaDocumentale.Documentale.AclEventListener(userInfo); //eventsNotification.DocumentoCreatoEventHandler(document, role, ruoliSuperiori); //Salvataggio del file associato al documento DocsPaVO.documento.FileRequest fileRequest = (DocsPaVO.documento.FileRequest)document.documenti[0]; fileRequest = BusinessLogic.Documenti.FileManager.putFile(fileRequest, fileDoc, userInfo); if(fileRequest == null) throw new ApplicationException("Si è verificato un errore nell'upload del documento per la stampa del registro di conservazione"); } superiori = ruoliSuperiori; if (superiori == null) superiori = new Ruolo[] { }; //Restituzione del numero documento return document.docNumber; }
private string SaveDocument(InfoUtente infoUtente, Ruolo role, SchedaDocumento schedaDoc, FileDocumento fileDoc) { //Salvataggio del documento DocsPaDocumentale.Documentale.DocumentManager docManager = new DocsPaDocumentale.Documentale.DocumentManager(infoUtente); //Salvataggio dell'oggetto schedaDoc = ProtoManager.addOggettoLocked(infoUtente.idAmministrazione, schedaDoc); Ruolo[] ruoliSuperiori; if (docManager.CreateDocumentoGrigio(schedaDoc, role, out ruoliSuperiori)) { //Salvataggio del file associato al documento DocsPaVO.documento.FileRequest fileRequest = (DocsPaVO.documento.FileRequest)schedaDoc.documenti[0]; fileRequest = BusinessLogic.Documenti.FileManager.putFile(fileRequest, fileDoc, infoUtente); if (fileRequest == null) { throw new ApplicationException("Si è verificato un errore nell'upload del documento di certificazione"); } } /* * superiori = ruoliSuperiori; * if (superiori == null) * superiori = new Ruolo[] { }; * */ //restituzione numero documento return(schedaDoc.docNumber); }
/// <summary> /// Operazione per il reperimento di un file di una versione / allegato di un documento /// /// PreCondizioni: /// la versione / allegato deve essere gi� stato creato come entit� persistente /// il file deve essere gi� acquisito nel repository documentale /// /// PostCondizioni: /// i seguenti attributi dell'oggetto "FileDocumento" devono essere inizializzati: /// - name (nome "fittizio" del file con estensione) /// - estensioneFile (estensione del file) /// - content (array di byte, contenuto del file) /// - contentType (mimetype del file) /// - length (dimensione dell'array di byte) /// </summary> /// <param name="fileDocumento"></param> /// <param name="fileRequest"></param> /// <param name="idamministrazione"></param> /// <returns></returns> public bool GetFile(ref DocsPaVO.documento.FileDocumento fileDocumento, ref DocsPaVO.documento.FileRequest fileRequest) { logger.Info("BEGIN"); bool retValue = false; try { // Il reperimento dei file viene dapprima effettuato dal documentale ETNOTEAM retValue = this.DocumentManagerETDOCS.GetFile(ref fileDocumento, ref fileRequest); } catch (Exception ex) { logger.Debug("Errore nel reperimento del file nel documentale ETNOTEAM", ex); // Errore nel reperimento del file nel documentale ETNOTEAM retValue = false; } logger.Info("END"); return(retValue); }
/// <summary> /// Operazione per l'inserimento di un file in una versione / allegato di un documento /// /// PreCondizione: /// la versione / allegato deve essere gi� stato creato come entit� persistente /// /// Attributi dell'oggetto FileRequest gi� valorizzati in ingresso /// VersionId: ID della versione / allegato in docspa /// Version: 0 se allegato, > 0 se versione /// SubVersion: ! se allegato, stringa vuota se versione /// VersionLabel: A# se allegato (dove # � il num. dell'allegato, fino a 99) /// (es. A01, A02, A03, ecc.) /// 1, 2, 3, 4, ecc. se versione /// PostCondizioni: /// il file deve essere stato associato alla versione / allegato /// /// </summary> /// <param name="fileRequest"></param> /// <param name="fileDocumento"></param> /// <param name="estensione"></param> /// <param name="objSicurezza"></param> /// <returns></returns> public bool PutFile(DocsPaVO.documento.FileRequest fileRequest, DocsPaVO.documento.FileDocumento fileDocumento, string estensione) { logger.Info("BEGIN"); bool retValue = false; try { //CHIAMATA AL DOCUMENTALE ETDOCS retValue = this.DocumentManagerETDOCS.PutFile(fileRequest, fileDocumento, estensione); DocsPaDB.Query_DocsPAWS.Documenti documenti = new DocsPaDB.Query_DocsPAWS.Documenti(); SchedaDocumento scheda = documenti.GetDettaglioNoSecurity( this._infoUtente, fileRequest.docNumber, fileRequest.docNumber); //if (retValue && (scheda.interop == null || scheda.interop.ToUpper() != "I" )) // retValue = this.DocumentManagerWSPIA.PutFile(fileRequest, fileDocumento, estensione); if (retValue && scheda.interop == null) { retValue = this.DocumentManagerWSPIA.PutFile(fileRequest, fileDocumento, estensione); } } catch (Exception ex) { logger.Debug(string.Format("Errore nel metodo PutFile: {0}", ex.Message)); logger.Debug(string.Format("Errore durante la scrittura del documento: {0}, non è stato possibile invocare il WebService di INPS", ex.Message)); } logger.Info("END"); return(retValue); }
/// <summary> /// Putfile chiamato per l'inserimento in SharePoint del documento. /// </summary> /// <param name="fileforcontenct">Oggetto dal quale prendo i byte del File</param> /// <param name="schedaDocBase">Scheda documento, usata per i parametri in SharePoint</param> /// <param name="_infoutente">Info Utente</param> /// <param name="fileRequest">Oggetto utile alla get del nome file e del Path</param> /// <param name="extention">Estensione del file da inserire nel documentale (es:doc)</param> /// <returns>True false a seconda dell'esito del PUT, non uso Try catch per far tornare l'errore originale</returns> public static bool PutFileInSP(ref DocsPaVO.documento.FileDocumento fileforcontenct, ref SchedaDocumento schedaDocBase, DocsPaVO.utente.InfoUtente _infoutente, ref DocsPaVO.documento.FileRequest fileRequest, string extention) { string sRemoteFileURL = null; string sSPURL = GetServerRoot(); //Istanzio il service SPCopy.Copy sp2010VmCopyService2Put = new SPCopy.Copy(); //Setto le credenziali con le mie prese da db sp2010VmCopyService2Put.Credentials = GetCredentialSP(); //eeeeeee //sp2010VmCopyService2Put.Url = string.Format("{0}/{1}", GetServerProtocollo() + GetServerRootnosites(), "_vti_bin/copy.asmx"); sp2010VmCopyService2Put.Url = string.Format("{0}{1}/{2}/{3}", GetServerProtocollo(), GetServerRootnosites(), GetLibraryRoot(DateTime.Now.Year.ToString(), _infoutente.codWorkingApplication).Replace(@"/", "\\").ToUpper(), "_vti_bin/copy.asmx"); //Nome file sRemoteFileURL = string.Format("{0}_{1}.{2}", _infoutente.codWorkingApplication, fileRequest.versionId, extention); //Url di destinazione sotto SP per la scrittura del file string[] destinationUrls = { Uri.EscapeUriString(GetServerProtocollo() + fileRequest.path) }; //Faccio la Get della UO da passare nei Metadati DocsPaDB.Query_DocsPAWS.Utenti utentiDb = new DocsPaDB.Query_DocsPAWS.Utenti(); DocsPaVO.utente.Ruolo ruolo = utentiDb.GetRuolo(_infoutente.idCorrGlobali, false); schedaDocBase.creatoreDocumento.uo_codiceCorrGlobali = ruolo.uo.codice; //Imposto i metadati. //correzione sabrina -- tutto l'oggetto fileRequest SPCopy.FieldInformation[] myFieldInfoArray = ImpostaMetaDati(ref schedaDocBase, _infoutente, fileRequest); //SPCopy.FieldInformation[] myFieldInfoArray = ImpostaMetaDati(ref schedaDocBase, _infoutente, fileRequest.version); SPCopy.CopyResult[] result; //Put del file sotto Sharepoint e sotto la sitecollection corretta sp2010VmCopyService2Put.CopyIntoItems(sRemoteFileURL, destinationUrls, myFieldInfoArray, fileforcontenct.content, out result); //Gestione errori: if (result[0].ErrorCode != SPCopy.CopyErrorCode.Success) { Console.WriteLine("Error occured during document upload process."); throw new Exception("Error Occured!" + result[0].ErrorCode); } //metadati null SPCopy.FieldInformation myFieldInfo = new SPCopy.FieldInformation(); SPCopy.FieldInformation[] myFieldInfoArrayNull = { myFieldInfo }; byte[] myByteArray; //Faccio la Get solo ed esclusivamente per valorizzare il nuovo contenct[] e il suo lenght. uint myGetUint = sp2010VmCopyService2Put.GetItem(destinationUrls[0], out myFieldInfoArrayNull, out myByteArray); //valorizzo. if (myByteArray == null || myByteArray.Length == 0) { return(false); } fileforcontenct.content = myByteArray; fileforcontenct.length = myByteArray.Length; //Ok torno. return(true); }
/// <summary> /// Modifica dei metadati di una versione /// </summary> /// <param name="fileRequest"></param> public void ModifyVersion(DocsPaVO.documento.FileRequest fileRequest) { try { this.DocumentManagerETDOCS.ModifyVersion(fileRequest); } catch (Exception ex) { string errorMessage = string.Format("Errore nell'operazione 'ModifyVersion': {0}", ex.Message); logger.Debug(errorMessage, ex); } }
/// <summary> /// Modifica dei metadati di una versione /// </summary> /// <param name="fileRequest"></param> public void ModifyVersion(DocsPaVO.documento.FileRequest fileRequest) { try { //TODO: gestire la transazionalità dei metodi this.DocumentManagerETDOCS.ModifyVersion(fileRequest); this.DocumentManagerOCS.ModifyVersion(fileRequest); } catch (Exception ex) { string errorMessage = string.Format("Errore nell'operazione 'ModifyVersion': {0}", ex.Message); logger.Debug(errorMessage, ex); throw ex; } }
/// <summary> /// /// </summary> /// <param name="fileRequest"></param> /// <param name="docNumber"></param> /// <param name="version_id"></param> /// <param name="version"></param> /// <param name="subVersion"></param> /// <param name="versionLabel"></param> /// <returns></returns> public bool ModifyExtension(ref DocsPaVO.documento.FileRequest fileRequest, string docNumber, string version_id, string version, string subVersion, string versionLabel) { bool retValue = false; try { retValue = this.DocumentManagerETDOCS.ModifyExtension(ref fileRequest, docNumber, version_id, version, subVersion, versionLabel); } catch (Exception ex) { string errorMessage = string.Format("Errore nell'operazione 'ModifyExtension': {0}", ex.Message); logger.Debug(errorMessage, ex); retValue = false; } return(retValue); }
/// <summary> /// /// </summary> /// <param name="infoUtente"></param> /// <param name="idDocumento"></param> /// <returns></returns> private static string getFileName(DocsPaVO.utente.InfoUtente infoUtente, string docNumber) { string versID = BusinessLogic.Documenti.VersioniManager.getLatestVersionID(docNumber, infoUtente); DocsPaVO.documento.FileRequest fileRq = new DocsPaVO.documento.FileRequest { docNumber = docNumber, versionId = versID }; string retval = BusinessLogic.Documenti.FileManager.getFileName(versID, docNumber); if (String.IsNullOrEmpty(retval)) { return(string.Empty); } else { return(retval); } }
/// <summary> /// Operazione per il reperimento di un file di una versione / allegato di un documento /// /// PreCondizioni: /// la versione / allegato deve essere gi� stato creato come entit� persistente /// il file deve essere gi� acquisito nel repository documentale /// /// PostCondizioni: /// i seguenti attributi dell'oggetto "FileDocumento" devono essere inizializzati: /// - name (nome "fittizio" del file con estensione) /// - estensioneFile (estensione del file) /// - content (array di byte, contenuto del file) /// - contentType (mimetype del file) /// - length (dimensione dell'array di byte) /// </summary> /// <param name="fileDocumento"></param> /// <param name="fileRequest"></param> /// <param name="idamministrazione"></param> /// <returns></returns> public bool GetFile(ref DocsPaVO.documento.FileDocumento fileDocumento, ref DocsPaVO.documento.FileRequest fileRequest) { logger.Info("BEGIN"); bool retValue = false; DocsPaDB.Query_DocsPAWS.Documenti documenti = new DocsPaDB.Query_DocsPAWS.Documenti(); List <BaseInfoDoc> listaSchedeDoc = documenti.GetBaseInfoForDocument(null, fileRequest.docNumber, null); BaseInfoDoc schedaDocBase = listaSchedeDoc[0]; SchedaDocumento schedaDocumento = documenti.GetDettaglioNoSecurity(this._infoUtente, schedaDocBase.IdProfile, schedaDocBase.DocNumber); try { if (!string.IsNullOrEmpty(_infoUtente.codWorkingApplication) && _infoUtente.codWorkingApplication == "DOCSPA") //Devo verificare che il path del doc non sia di tipo vecchio, se è vecchio giro a ETDOCS. //porcata: { //Qui devo trovare un modo elegante per farlo, per ora faccio così. string sSPURL = System.Configuration.ConfigurationSettings.AppSettings["SP_Server"]; if (fileRequest.fileName.ToUpper().Contains(DocsPaDocumentale_SP.WsSPServices.CallerSP.GetServerRootnosites().ToUpper()) || fileRequest.path.ToUpper().Contains(DocsPaDocumentale_SP.WsSPServices.CallerSP.GetServerRootnosites().ToUpper())) { retValue = this.DocumentManagerSP.GetFile(ref fileDocumento, ref fileRequest); } else { retValue = this.DocumentManagerETDOCS.GetFile(ref fileDocumento, ref fileRequest); } } else { retValue = this.DocumentManagerETDOCS.GetFile(ref fileDocumento, ref fileRequest); } } catch (Exception ex) { logger.Debug("Errore nel reperimento del file nel documentale ETNOTEAM", ex); // Errore nel reperimento del file nel documentale ETNOTEAM retValue = false; } logger.Info("END"); return(retValue); }
/// <summary> /// Operazione per il reperimento di un file di una versione / allegato di un documento /// /// PreCondizioni: /// la versione / allegato deve essere già stato creato come entità persistente /// il file deve essere già acquisito nel repository documentale /// /// PostCondizioni: /// i seguenti attributi dell'oggetto "FileDocumento" devono essere inizializzati: /// - name (nome "fittizio" del file con estensione) /// - estensioneFile (estensione del file) /// - content (array di byte, contenuto del file) /// - contentType (mimetype del file) /// - length (dimensione dell'array di byte) /// </summary> /// <param name="fileDocumento"></param> /// <param name="fileRequest"></param> /// <param name="idamministrazione"></param> /// <returns></returns> public bool GetFile(ref DocsPaVO.documento.FileDocumento fileDocumento, ref DocsPaVO.documento.FileRequest fileRequest) { logger.Info("BEGIN"); bool retValue = false; if (this.PitreDualFileWritingMode) { // E' attiva la modalità di scrittura dei file su entrambi i documentali try { //// Il reperimento dei file viene dapprima effettuato dal documentale DTCM //retValue = this.DocumentManagerDocumentum.GetFile(ref fileDocumento, ref fileRequest); // modifica per migrazione. Controllo prima nel file system retValue = this.DocumentManagerETDOCS.GetFile(ref fileDocumento, ref fileRequest); } catch (Exception ex) { logger.Debug("Errore nel reperimento del file nel documentale DTCM", ex); // Errore nel reperimento del file nel documentale ETNOTEAM retValue = false; } if (!retValue) { //// In caso di errore nel reperimento del file in ETNOTEAM, viene richiamato //// il corrispondente metodo in documentum //retValue = this.DocumentManagerETDOCS.GetFile(ref fileDocumento, ref fileRequest); // modifica per migrazione. Quindi cerco in DCTM retValue = this.DocumentManagerDocumentum.GetFile(ref fileDocumento, ref fileRequest); } } else { retValue = this.DocumentManagerDocumentum.GetFile(ref fileDocumento, ref fileRequest); } logger.Info("END"); return(retValue); }
/// <summary> /// Rimozione di una versione /// </summary> /// <param name="fileRequest"></param> /// <returns></returns> public bool RemoveVersion(DocsPaVO.documento.FileRequest fileRequest) { bool retValue = false; using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext()) { retValue = this.DocumentManagerETDOCS.RemoveVersion(fileRequest); if (retValue) { retValue = this.DocumentManagerOCS.RemoveVersion(fileRequest); } if (retValue) { transactionContext.Complete(); } } return(retValue); }
/// <summary> /// Reperimento file associato al documento /// </summary> /// <param name="infoUtente"></param> /// <param name="docNumber"></param> /// <returns></returns> private static DocsPaVO.documento.FileDocumento GetFile(DocsPaVO.utente.InfoUtente infoUtente, string docNumber) { DocsPaVO.documento.SchedaDocumento schedaDocumento = BusinessLogic.Documenti.DocManager.getDettaglioNoSecurity(infoUtente, docNumber); DocsPaVO.documento.FileRequest fileRequest = (DocsPaVO.documento.FileRequest)schedaDocumento.documenti[0]; DocsPaVO.documento.FileDocumento retVal = null; try { if (IsFileAcquired(fileRequest)) { //retVal = BusinessLogic.Documenti.FileManager.getFile(fileRequest, infoUtente); //prelevo il file firmato se presente e non lo sbustato retVal = BusinessLogic.Documenti.FileManager.getFileFirmato(fileRequest, infoUtente, false); // Download del file associato al documento } } catch (Exception ex) { } return(retVal); }
/// <summary> /// Rimozione di una versione del documento /// </summary> /// <param name="fileRequest"></param> /// <param name="infoUtente"></param> /// <returns></returns> public static bool removeVersion(DocsPaVO.documento.FileRequest fileRequest, DocsPaVO.utente.InfoUtente infoUtente) { if (fileRequest.repositoryContext == null) { // Verifica stato di consolidamento del documento DocumentConsolidation.CanExecuteAction(infoUtente, fileRequest.docNumber, DocumentConsolidation.ConsolidationActionsDeniedEnum.RemoveVersions, true); } logger.Debug("removeVersion"); bool result = false; using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext()) { DocsPaDocumentale.Documentale.DocumentManager documentManager = new DocsPaDocumentale.Documentale.DocumentManager(infoUtente); result = documentManager.RemoveVersion(fileRequest); if (result) { transactionContext.Complete(); } } return(result); }
/// <summary> /// /// </summary> /// <param name="infoUtente"></param> /// <param name="fileReq"></param> public static void modificaVersione(DocsPaVO.utente.InfoUtente infoUtente, DocsPaVO.documento.FileRequest fileReq) { try { if (fileReq.repositoryContext == null) { // Verifica stato di consolidamento del documento DocumentConsolidation.CanExecuteAction(infoUtente, fileReq.docNumber, DocumentConsolidation.ConsolidationActionsDeniedEnum.RemoveVersions, true); } using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext()) { DocsPaDocumentale.Documentale.DocumentManager documentManager = new DocsPaDocumentale.Documentale.DocumentManager(infoUtente); documentManager.ModifyVersion(fileReq); transactionContext.Complete(); } } catch (Exception ex) { logger.Debug(ex.Message); } }
/// <summary> /// </summary> /// <param name="fileRequest"></param> /// <param name="infoUtente"></param> /// <param name="daInviare"></param> /// <returns></returns> public static DocsPaVO.documento.FileRequest addVersion(DocsPaVO.documento.FileRequest fileRequest, DocsPaVO.utente.InfoUtente infoUtente, bool daInviare) { logger.Info("BEGIN"); logger.Debug("addVersion"); if (fileRequest.repositoryContext != null) { if (!daInviare) { // Inserimento della versione nel repositorycontext (il documento ancora non è stato salvato) int newVersion, newVersionLabel; Int32.TryParse(fileRequest.version, out newVersion); Int32.TryParse(fileRequest.versionLabel, out newVersionLabel); fileRequest.subVersion = "!"; fileRequest.version = (newVersion + 1).ToString(); fileRequest.versionLabel = (newVersionLabel + 1).ToString(); } } else { // Verifica stato di consolidamento del documento DocumentConsolidation.CanExecuteAction(infoUtente, fileRequest.docNumber, DocumentConsolidation.ConsolidationActionsDeniedEnum.AddVersions, true); if (!LibroFirma.LibroFirmaManager.CanExecuteAction(fileRequest, infoUtente)) { throw new Exception("Non è possibile creare la versione poichè il documento principale è in libro firma"); } DocsPaDocumentale.Documentale.DocumentManager documentManager = new DocsPaDocumentale.Documentale.DocumentManager(infoUtente); if (!documentManager.AddVersion(fileRequest, daInviare)) { fileRequest = null; } } logger.Info("END"); return(fileRequest); }
/// <summary> /// Operazione per l'inserimento di un file in una versione / allegato di un documento /// /// PreCondizione: /// la versione / allegato deve essere gi� stato creato come entit� persistente /// /// Attributi dell'oggetto FileRequest gi� valorizzati in ingresso /// VersionId: ID della versione / allegato in docspa /// Version: 0 se allegato, > 0 se versione /// SubVersion: ! se allegato, stringa vuota se versione /// VersionLabel: A# se allegato (dove # � il num. dell'allegato, fino a 99) /// (es. A01, A02, A03, ecc.) /// 1, 2, 3, 4, ecc. se versione /// PostCondizioni: /// il file deve essere stato associato alla versione / allegato /// /// </summary> /// <param name="fileRequest"></param> /// <param name="fileDocumento"></param> /// <param name="estensione"></param> /// <param name="objSicurezza"></param> /// <returns></returns> public bool PutFile(DocsPaVO.documento.FileRequest fileRequest, DocsPaVO.documento.FileDocumento fileDocumento, string estensione) { logger.Info("BEGIN"); bool retValue = false; //CONTROLLO SULL?APP CHE MI CHIAMA!!!!!!!!!!!!!!!! DocsPaDB.Query_DocsPAWS.Documenti documenti = new DocsPaDB.Query_DocsPAWS.Documenti(); List <BaseInfoDoc> listaSchedeDoc = documenti.GetBaseInfoForDocument(null, fileRequest.docNumber, null); BaseInfoDoc schedaDocBase = listaSchedeDoc[0]; SchedaDocumento schedaDocumento = documenti.GetDettaglioNoSecurity(this._infoUtente, schedaDocBase.IdProfile, schedaDocBase.DocNumber); //FINE try { //************************************ // _infoUtente.codWorkingApplication * //************************************ if (!string.IsNullOrEmpty(_infoUtente.codWorkingApplication) && _infoUtente.codWorkingApplication == "DOCSPA") { //CHIAMATA AL DOCUMENTALE SHAREPOINT retValue = this.DocumentManagerSP.PutFile(fileRequest, fileDocumento, estensione); } else { //CHIAMATA AL DOCUMENTALE ETDOCS retValue = this.DocumentManagerETDOCS.PutFile(fileRequest, fileDocumento, estensione); } } catch (Exception ex) { logger.Debug(string.Format("Errore nel metodo PutFile: {0}", ex.Message)); logger.Debug(string.Format("Errore durante la scrittura del documento: {0}, non è stato possibile invocare il WebService di INPS", ex.Message)); retValue = false; } logger.Info("END"); return(retValue); }
private static MarcaTemporale extractMarcaTemporale(DocsPaVO.documento.FileRequest objFileRequest, DocsPaVO.utente.InfoUtente infoUtente) { MarcaTemporale mt = null; var ts = BusinessLogic.Documenti.TimestampManager.getTimestampsDoc(infoUtente, objFileRequest); if (ts.Count > 0) { mt = new MarcaTemporale(); DocsPaVO.documento.TimestampDoc timestampDoc = ts[0] as DocsPaVO.documento.TimestampDoc; if (timestampDoc != null) { mt.NumeroSerie = timestampDoc.NUM_SERIE; mt.SNCertificato = timestampDoc.S_N_CERTIFICATO; mt.ImprontaDocumentoAssociato = timestampDoc.TSR_FILE; mt.DataInizioValidita = Utils.formattaData(Utils.convertiData(timestampDoc.DTA_CREAZIONE)); mt.DataFineValidita = Utils.formattaData(Utils.convertiData(timestampDoc.DTA_SCADENZA)); mt.TimeStampingAuthority = timestampDoc.SOGGETTO; mt.Data = Utils.formattaData(Utils.convertiData(timestampDoc.DTA_CREAZIONE));; mt.Ora = Utils.formattaOraScondi(Utils.convertiData(timestampDoc.DTA_CREAZIONE)); } } return(mt); }
/// <summary> /// Operazione per l'inserimento di un file in una versione / allegato di un documento /// /// PreCondizione: /// la versione / allegato deve essere già stato creato come entità persistente /// /// Attributi dell'oggetto FileRequest già valorizzati in ingresso /// VersionId: ID della versione / allegato in docspa /// Version: 0 se allegato, > 0 se versione /// SubVersion: ! se allegato, stringa vuota se versione /// VersionLabel: A# se allegato (dove # è il num. dell'allegato, fino a 99) /// (es. A01, A02, A03, ecc.) /// 1, 2, 3, 4, ecc. se versione /// PostCondizioni: /// il file deve essere stato associato alla versione / allegato /// /// </summary> /// <param name="fileRequest"></param> /// <param name="fileDocumento"></param> /// <param name="estensione"></param> /// <param name="objSicurezza"></param> /// <returns></returns> public bool PutFile(DocsPaVO.documento.FileRequest fileRequest, DocsPaVO.documento.FileDocumento fileDocumento, string estensione) { //Performance.PerformanceLogWriter.CreatePerformanceLogWriter(@"c:\temp\DocumentManager.txt"); //Performance.PerformanceLogWriter log = new Performance.PerformanceLogWriter(); //log.StartLogEntry("PutFile"); bool retValue = false; try { // Inserimento del file in OCS retValue = this.DocumentManagerOCS.PutFile(fileRequest, fileDocumento, estensione); if (retValue) { // Aggiornamento attributi filerequest // Per OCS abbiamo cambiato il nome del file, non il version_id ma il docNumber //fileRequest.fileName = string.Format("{0}.{1}", fileRequest.versionId, estensione); fileRequest.fileName = string.Format("{0}.{1}", fileRequest.docNumber, estensione); fileRequest.fileSize = fileDocumento.content.Length.ToString(); this.SetFileAsInserted(fileRequest, fileDocumento.content); } } catch (Exception ex) { logger.Debug(string.Format("Errore nel metodo PutFile: {0}", ex.Message)); retValue = false; } //log.EndLogEntry(); //Performance.PerformanceLogWriter.FlushPerformanceLogWriter(); return(retValue); }
public XmlDocumento(InfoConservazione infoCons, DocsPaVO.documento.FileDocumento fileDoc, DocsPaVO.documento.SchedaDocumento schDoc, DocsPaVO.documento.FileRequest objFileRequest) { if (this.documento == null) { documento = new Documento.Documento(); } DocsPaVO.utente.Ruolo ruolo = BusinessLogic.Utenti.UserManager.getRuolo(infoCons.IdRuoloInUo); DocsPaVO.utente.InfoUtente infoUtente = BusinessLogic.Utenti.UserManager.GetInfoUtente(UserManager.getUtente(infoCons.IdPeople), ruolo); DocsPaVO.utente.UnitaOrganizzativa unitaOrganizzativa = ruolo.uo; List <UnitaOrganizzativa> uoL = new List <UnitaOrganizzativa>(); UnitaOrganizzativa uoXML = Utils.convertiUO(unitaOrganizzativa); uoL.Add(uoXML); documento.SoggettoProduttore = new SoggettoProduttore { Amministrazione = Utils.getInfoAmministrazione(infoCons), GerarchiaUO = new GerarchiaUO { UnitaOrganizzativa = uoL.ToArray() }, Creatore = Utils.getCreatore(infoCons, ruolo) }; documento.IDistanza = infoCons.SystemID; documento.IDdocumento = schDoc.systemId; documento.Oggetto = schDoc.oggetto.descrizione; documento.Tipo = Utils.convertiTipoPoto(schDoc); // documento.DataCreazione = Utils.formattaData(Utils.convertiData(schDoc.dataCreazione)); documento.DataCreazione = schDoc.dataCreazione; if (schDoc.privato != null && schDoc.privato.Equals("1")) { documento.LivelloRiservatezza = "privato"; } else { documento.LivelloRiservatezza = string.Empty; } documento.File = getFileDetail(fileDoc, objFileRequest, infoUtente); documento.Registrazione = getRegistrazione(infoCons, schDoc, ruolo); documento.ContestoArchivistico = getContestoArchivistico(infoCons, schDoc, ruolo, infoUtente); if (schDoc.template != null) { Tipologia t = new Tipologia { NomeTipologia = schDoc.template.DESCRIZIONE, CampoTipologia = Utils.getCampiTipologia(schDoc.template) }; documento.Tipologia = t; } documento.Allegati = getAllegati(schDoc, infoUtente); }
public string InviaRelata(byte[] fileReleata, String Stato, string token) { AlboToken at = new AlboToken(); AlboTokenVO tvo = at.DecryptToken(token); String docNumber = tvo.DocNumber; String nomeFile = "Relata.pdf"; string IdAmministrazione = BusinessLogic.Utenti.UserManager.getIdAmmUtente(tvo.userID); DocsPaVO.utente.Utente utente = BusinessLogic.Utenti.UserManager.getUtente(tvo.userID, IdAmministrazione); utente.dst = BusinessLogic.Utenti.UserManager.getSuperUserAuthenticationToken(); if (utente == null) { throw new ApplicationException(string.Format("Utente {0} non trovato", tvo.userID)); } DocsPaVO.utente.Ruolo[] ruoli = (DocsPaVO.utente.Ruolo[])BusinessLogic.Utenti.UserManager.getRuoliUtente(utente.idPeople).ToArray(typeof(DocsPaVO.utente.Ruolo)); if (ruoli != null && ruoli.Length > 0) { throw new ApplicationException("L'utente non non risulta associato ad alcun ruolo"); } DocsPaVO.utente.InfoUtente infoUtente = new DocsPaVO.utente.InfoUtente(utente, ruoli[0]); DocsPaVO.documento.Allegato all = new DocsPaVO.documento.Allegato(); all.descrizione = "Relata di Pubblicazione"; all.docNumber = docNumber; all.fileName = nomeFile; all.version = "0"; all.numeroPagine = 1; DocsPaVO.documento.Allegato allIns = null; String err = String.Empty; try { allIns = BusinessLogic.Documenti.AllegatiManager.aggiungiAllegato(infoUtente, all); } catch (Exception ex) { logger.DebugFormat("Problemi nell'inserire l'allegato per la relata di pubblicazione {0} \r\n {1}", ex.Message, ex.StackTrace); } try { DocsPaVO.documento.SchedaDocumento sd = BusinessLogic.Documenti.DocManager.getDettaglioNoSecurity(infoUtente, docNumber); DocsPaVO.documento.FileDocumento fdAll = new DocsPaVO.documento.FileDocumento(); fdAll.content = fileReleata; fdAll.length = fileReleata.Length; fdAll.name = nomeFile; fdAll.bypassFileContentValidation = true; DocsPaVO.documento.FileRequest fRAll = (DocsPaVO.documento.FileRequest)sd.documenti[0]; fRAll = (DocsPaVO.documento.FileRequest)all; if (fdAll.content.Length > 0) { logger.Debug("controllo se esiste l'ext"); if (!BusinessLogic.Documenti.DocManager.esistiExt(nomeFile)) { BusinessLogic.Documenti.DocManager.insertExtNonGenerico(nomeFile, "application/octet-stream"); } if (!BusinessLogic.Documenti.FileManager.putFile(ref fRAll, fdAll, infoUtente, out err)) { logger.Debug("errore durante la putfile"); } } } catch (Exception ex) { if (err == "") { err = string.Format("Errore nel reperimento del file allegato: {0}. {1}", nomeFile, ex.Message); } BusinessLogic.Documenti.AllegatiManager.rimuoviAllegato(all, infoUtente); logger.Debug(err); } //Mettere il cambio di stato. return("OK"); }
/// <summary> /// /// </summary> /// <param name="fr"></param> /// <param name="daInviare"></param> private static void updateVersion(DocsPaVO.documento.FileRequest fr, bool daInviare) { DocsPaDB.Query_DocsPAWS.Documenti doc = new DocsPaDB.Query_DocsPAWS.Documenti(); doc.UpdateVersionManager(fr, daInviare); }
/// <summary> /// Elimina il documento della coda di conversione pdf lato server /// </summary> /// <returns></returns> public static void DequeueServerPdfConversion(string nameDocConvertito, string nameFileXml, byte[] docConvertito, byte[] xml, ref DocsPaVO.utente.InfoUtente infoUser, ref string noteLog, ref DocsPaVO.documento.SchedaDocumento sDoc) { logger.Debug( string.Format("INIZIO: EnqueueServerPdfConversion, nameDocConvertito: '{0}', nameFileXml: '{1}', docConvertiro: '{2}', xml: '{3}'", nameDocConvertito, nameFileXml, (docConvertito != null ? docConvertito.Length.ToString() : "NULL"), (xml != null ? xml.Length.ToString() : "NULL"))); DocsPaVO.utente.InfoUtente infoUtente = null; DocsPaVO.documento.SchedaDocumento schedaDocPrincipale = null; //string noteGeneraliTrasmissione = string.Empty; using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext()) { try { logger.Debug("INIZIO - Lettura file xml di metadati"); // 1. Lettura file xml di metadati MemoryStream ms = new MemoryStream(xml); XmlDocument xDoc = new XmlDocument(); xDoc.Load(ms); XmlNode node = xDoc.DocumentElement; logger.Debug("Creazione infoUtente"); //Creazione infoUtente infoUtente = new DocsPaVO.utente.InfoUtente(); infoUtente.dst = node.SelectSingleNode("DST").InnerText.ToString(); infoUtente.idAmministrazione = node.SelectSingleNode("ID_AMM").InnerText.ToString(); infoUtente.idCorrGlobali = node.SelectSingleNode("ID_CORR_GLOBALI").InnerText.ToString(); infoUtente.idGruppo = node.SelectSingleNode("ID_GRUPPO").InnerText.ToString(); infoUtente.idPeople = node.SelectSingleNode("ID_PEOPLE").InnerText.ToString(); infoUtente.sede = node.SelectSingleNode("SEDE").InnerText.ToString(); infoUtente.urlWA = node.SelectSingleNode("URLWA").InnerText.ToString(); infoUtente.userId = node.SelectSingleNode("USERID").InnerText.ToString(); if (node.SelectSingleNode("ID_PEOPLE_DELEGATO") != null && !string.IsNullOrEmpty(node.SelectSingleNode("ID_PEOPLE_DELEGATO").ToString())) { infoUtente.delegato = new DocsPaVO.utente.InfoUtente() { idPeople = node.SelectSingleNode("ID_PEOPLE_DELEGATO").InnerText.ToString() }; } infoUser = infoUtente; logger.Debug("Creazione fileRequest"); //Creazione FileRequest DocsPaVO.documento.FileRequest fileRequest = new DocsPaVO.documento.FileRequest(); fileRequest.autore = node.SelectSingleNode("AUTORE").InnerText.ToString(); fileRequest.dataInserimento = node.SelectSingleNode("DATA_INSERIMENTO").InnerText.ToString(); fileRequest.descrizione = node.SelectSingleNode("DESCRIZIONE").InnerText.ToString(); fileRequest.docNumber = node.SelectSingleNode("DOCNUMBER").InnerText.ToString(); string OriginalfileName = null; try { //potrebbe non esistere OriginalfileName = node.SelectSingleNode("ORIGINAL_FILE_NAME").InnerText.ToString(); } catch { logger.Debug("ORIGINAL_FILE_NAME non presente"); } //Faillace : provo nel caso sia codificato in base 64 (modifica del 4-6-2014) try { if (OriginalfileName != null) { byte[] ofnBytes = Convert.FromBase64String(OriginalfileName); if (ofnBytes != null) { OriginalfileName = System.Text.UTF8Encoding.UTF8.GetString(ofnBytes); } } } catch { // se entro nella catch il filename non è codificato base64, non defo fare nulla perchè il nome file sarà // in chiaro, ma avrà le accentate errate in quanto convertito ascii // se prensente un punto interrogativo (non ammesso nel filename ma introdotto dal convertitore) lo converto in underscore. if (OriginalfileName != null) { OriginalfileName = OriginalfileName.Replace('?', '_'); } } logger.Debug("Informazioni documento"); //Recupero informazioni del documento string idProfile = node.SelectSingleNode("ID_PROFILE").InnerText.ToString(); string docNumber = node.SelectSingleNode("DOCNUMBER").InnerText.ToString(); logger.Debug("FINE - Lettura file xml di metadati"); // 2. Verifica se il documento è in stato di conversione PDF if (BusinessLogic.Documenti.DocManager.isDocInConversionePdf(idProfile)) { // 3. Controllo che il documento in stato di conversione sia in checkout dallo stesso utente logger.Debug("INIZIO - Reperimento dello stato di CheckOut del documento '{0}'"); DocsPaVO.CheckInOut.CheckOutStatus statusCheckOut = null; try { statusCheckOut = BusinessLogic.CheckInOut.CheckInOutServices.GetCheckOutStatus(idProfile, docNumber, infoUtente); } catch (Exception ex) { // 3a. Si è verificato un errore nel reperimento delle informazioni di stato del documento nel sistema documentale // In tali frangenti, non è possibile effettuare l'undo checkout nel sistema documentale e la conseguente rimozione del lock di conversione. // Pertanto sarà notificata una trasmissione di fallimento all'utente segnalando, tra le note individuali, che c'è stato un problema // nel sistema documentale e che il documento dovrà essere sbloccato a mano. //noteGeneraliTrasmissione = string.Format("Problemi durante la conversione in PDF per il documento '{0}'. " + // "Sarà necessario sbloccare manualmente il documento e ripetere l'operazione.", idProfile); noteLog = string.Format("Problemi durante la conversione in PDF per il documento '{0}'. " + "Sarà necessario sbloccare manualmente il documento e ripetere l'operazione.", idProfile); //throw new ApplicationException(noteGeneraliTrasmissione, ex); throw new ApplicationException(noteLog, ex); } logger.Debug("FINE - Reperimento dello stato di CheckOut del documento '{0}'"); if (statusCheckOut != null && statusCheckOut.DocumentNumber == fileRequest.docNumber && statusCheckOut.UserName.ToUpper() == infoUtente.userId.ToUpper()) { logger.Debug("DocNumber CheckOut : " + statusCheckOut.DocumentNumber); logger.Debug("DocNumber FileRequest : " + fileRequest.docNumber); logger.Debug("IdRole CheckOut : " + statusCheckOut.IDRole); logger.Debug("IdCorrGlobali infoUtente : " + infoUtente.idCorrGlobali); logger.Debug("UserName CheckOut : " + statusCheckOut.UserName); logger.Debug("UserName infoUtente : " + infoUtente.userId); statusCheckOut.DocumentLocation = nameDocConvertito; bool undoCheckOut = false; // Se il parametro "docConvertito" è null allora ci sono stati problemi nella conversione if (docConvertito != null) { // 4. CheckIn del documento if (!CheckIn(infoUtente, statusCheckOut, docConvertito, "Documento convertito in pdf lato server")) { // 4a. Errore in CheckIn, viene effettuato l'UndoCheckOut UndoCheckOut(infoUtente, statusCheckOut); undoCheckOut = true; } else { if (!String.IsNullOrEmpty(OriginalfileName)) { //documento convertito, gli rimetto il nome originale OriginalfileName = System.IO.Path.GetFileNameWithoutExtension(OriginalfileName) + ".pdf"; DocsPaVO.documento.FileRequest fr = (DocsPaVO.documento.FileRequest)BusinessLogic.Documenti.DocManager.getDettaglioNoSecurity(infoUtente, docNumber).documenti[0]; BusinessLogic.Documenti.FileManager.setOriginalFileName(infoUtente, fr, OriginalfileName, true); } } } else { // 4a. File non convertito, UndoCheckOut del documento UndoCheckOut(infoUtente, statusCheckOut); undoCheckOut = true; } logger.Debug("Recupero scheda documento"); DocsPaVO.documento.SchedaDocumento schDoc = null; try { // 5. Reperimento scheda del documento convertito schDoc = BusinessLogic.Documenti.DocManager.getDettaglioNoSecurity(infoUtente, docNumber); } catch (Exception ex) { // Errore nel reperimento del dettaglio del documento logger.Debug(ex); // NB. Nonostante l'errore, il documento è stato correttamente convertito (o meno) // e il checkin (o undocheckout) è stato effettauto correttamente. // Pertanto il reperimento della scheda è ininfluente e come nota generale // viene impostato l'id del documento, senza distinguere se principale o allegato //noteGeneraliTrasmissione = string.Format("Il documento '{0}' è stato convertito in PDF.", docNumber); noteLog = string.Format("Il documento '{0}' è stato convertito in PDF.", docNumber); } if (schDoc != null) { // Verifico se il doc convertito è un allegato bool isAllegato = (schDoc.documentoPrincipale != null); if (isAllegato) { try { // 5a. Reperimento scheda doc principale per l'allegato schedaDocPrincipale = BusinessLogic.Documenti.DocManager.getDettaglioNoSecurity( infoUtente, schDoc.documentoPrincipale.docNumber); } catch (Exception ex) { // Errore nel reperimento del dettaglio del documento allegato logger.Debug(ex); } if (undoCheckOut) { //noteGeneraliTrasmissione = string.Format("Problemi durante la conversione in PDF per l'allegato '{0}'. Ripetere l'operazione.", schDoc.docNumber); noteLog = string.Format("Problemi durante la conversione in PDF per l'allegato '{0}'. Ripetere l'operazione.", schDoc.docNumber); } else { // Impostazione note generali di trasmissione //noteGeneraliTrasmissione = string.Format("Allegato '{0}' convertito in PDF.", schDoc.docNumber); noteLog = string.Format("Allegato '{0}' convertito in PDF.", schDoc.docNumber); } } else { schedaDocPrincipale = schDoc; // Impostazione note generali di trasmissione string docName = string.Empty; if (schedaDocPrincipale.protocollo != null) { docName = schedaDocPrincipale.protocollo.segnatura; } else { docName = schedaDocPrincipale.docNumber; } if (undoCheckOut) { //noteGeneraliTrasmissione = string.Format("Problemi durante la conversione in PDF per il documento '{0}'. Ripetere l'operazione.", docName); noteLog = string.Format("Problemi durante la conversione in PDF per il documento '{0}'. Ripetere l'operazione.", docName); } else { //noteGeneraliTrasmissione = string.Format("Il documento '{0}' è stato convertito in PDF.", docName); noteLog = string.Format("Il documento '{0}' è stato convertito in PDF.", docName); } } } } else { logger.Debug(string.Format("Il documento '{0}' non è più bloccato nel sistema documentale per la conversione PDF", idProfile)); } } else { logger.Debug(string.Format("Il documento '{0}' non è più in coda di conversione PDF", idProfile)); } } catch (Exception ex) { logger.Debug("Errore in BusinessLogic.Documenti.LifeCyclePdfConverter.cs - metodo: DequeueServerPdfConversion", ex); } finally { sDoc = schedaDocPrincipale; //ExecuteTrasmissione(infoUtente, schedaDocPrincipale, noteGeneraliTrasmissione); // 6. Completamento della transazione in ogni caso transactionContext.Complete(); logger.Debug(string.Format("FINE: EnqueueServerPdfConversion, nameDocConvertito: '{0}', nameFileXml: '{1}', docConvertiro: '{2}', xml: '{3}'", nameDocConvertito, nameFileXml, (docConvertito != null ? docConvertito.Length.ToString() : "NULL"), (xml != null ? xml.Length.ToString() : "NULL"))); logger.Debug("Tramissione di notifica conversione"); } } }
/// <summary> /// /// </summary> /// <param name="fileRequest"></param> /// <returns></returns> protected bool IsAcquired(DocsPaVO.documento.FileRequest fileRequest) { DocsPaDB.Query_DocsPAWS.CheckInOut checkInOutDb = new DocsPaDB.Query_DocsPAWS.CheckInOut(); return(checkInOutDb.IsAcquired(fileRequest)); }
/// <summary> /// CheckIn del documento /// </summary> /// <param name="checkOutStatus"></param> /// <param name="content"></param> /// <param name="checkInComments"></param> /// <returns></returns> /// <remarks> /// Il documento è in checkout solo nel documentale ETDOCS, /// pertanto l'operazione di checkin, oltre ad effettuare il checkin in ETDOCS, /// dovrà aggiungere la nuova versione anche in DCTM. Ciò comporta /// l'utilizzo dei servizi di checkout e checkin del documentale DCTM. /// </remarks> public bool CheckIn(DocsPaVO.CheckInOut.CheckOutStatus checkOutStatus, byte[] content, string checkInComments) { bool retValue = false; // Stato del checkout temporaneo in DCTM // Flag, se true indica che il documento è temporaneamente in checkout in DCTM bool hasCheckedOutDCTM = false; // Flag, se true indica che per il documento è stata creata una versione in DCTM; // in tal caso il flag 'hasCheckedOutDCTM' deve essere nello stato "false" bool hasCheckedInDCTM = false; // Informazioni di stato checkout del documento in DCTM DocsPaVO.CheckInOut.CheckOutStatus checkOutStatusDCTM = null; int nextVersion = this.GetNextVersionId(checkOutStatus.IDDocument); try { // CheckOut del documento in DCTM per la creazione della versione in DCTM, if (this.CheckInOutManagerDCTM.CheckOut(checkOutStatus.IDDocument, checkOutStatus.DocumentNumber, checkOutStatus.DocumentLocation, checkOutStatus.MachineName, out checkOutStatusDCTM)) { hasCheckedOutDCTM = true; // CheckIn del documento in DCTM retValue = this.CheckInOutManagerDCTM.CheckIn(checkOutStatusDCTM, content, checkInComments); if (retValue) { hasCheckedOutDCTM = false; hasCheckedInDCTM = true; if (this.PitreDualFileWritingMode) { // In modalità doppia scrittura, viene effettuato il CheckIn del documento in ETDOCS // NB: L'implementazione del checkin in ETDOCS inserisce il file nel documentale retValue = this.CheckInOutManagerETDOCS.CheckIn(checkOutStatus, content, checkInComments); } else { // Doppia scrittura non attiva // Viene effettuato l'undocheckout del documento e inserita una nuova versione in ETDOCS this.CheckInOutManagerETDOCS.UndoCheckOut(checkOutStatus); // Creazione della versione del documento in ETDOCS retValue = this.CreateDocumentVersion(checkOutStatus, checkInComments, content); } } } } catch (Exception ex) { logger.Debug("Si è verificato un errore nel CheckIn del documento nel documentale PITRE", ex); retValue = false; } finally { if (!retValue) { try { // Operazioni di compensazione e ripristino in caso di errore if (hasCheckedOutDCTM && !hasCheckedInDCTM) { // Il documento è rimasto in checkout in DCTM, deve essere annullato if (this.CheckInOutManagerDCTM.UndoCheckOut(checkOutStatusDCTM)) { logger.Debug(string.Format("UndoCheckOut per il documento con DocNumber '{0}' in Documentum", checkOutStatus.DocumentNumber)); } } else if (!hasCheckedOutDCTM && hasCheckedInDCTM) { // Per il documento è stata creata una versione in DCTM, deve essere rimossa DocsPaVO.documento.FileRequest versionToDelete = this.GetFileRequest(checkOutStatus); bool isAcquired = this.IsAcquired(versionToDelete); if (isAcquired) { versionToDelete.version = nextVersion.ToString(); /* * IDocumentManager documentManager = new DocsPaDocumentale_DOCUMENTUM.Documentale.DocumentManager(this.InfoUtente); * * if (documentManager.RemoveVersion(versionToDelete)) * { * logger.Debug(string.Format("Versione '{0}' per il documento con DocNumber '{0}' rimossa in Documentum", versionToDelete.version, versionToDelete.docNumber)); * } */ } } } catch (Exception innerEx) { logger.Debug("Si è verificato un errore nelle operazioni di compensazione e ripristino del CheckIn del documento nel documentale PITRE", innerEx); } } } return(retValue); }
public XmlDocument(DocsPaVO.documento.FileDocumento fileDoc, DocsPaVO.documento.SchedaDocumento schDoc, DocsPaVO.documento.FileRequest objFileRequest, InstanceAccessDocument instanceDoc, DocsPaVO.utente.InfoUtente infoUtente) { if (this.documento == null) { documento = new DocsPaVO.InstanceAccess.Metadata.Document(); } DocsPaVO.utente.Ruolo ruolo = BusinessLogic.Utenti.UserManager.getRuolo(schDoc.creatoreDocumento.idCorrGlob_Ruolo); //DocsPaVO.utente.InfoUtente infoUtente = BusinessLogic.Utenti.UserManager.GetInfoUtente(BusinessLogic.Utenti.UserManager.getUtente(schDoc.creatoreDocumento.idPeople), ruolo); DocsPaVO.utente.UnitaOrganizzativa unitaOrganizzativa = ruolo.uo; List <DocsPaVO.InstanceAccess.Metadata.UnitaOrganizzativa> uoL = new List <DocsPaVO.InstanceAccess.Metadata.UnitaOrganizzativa>(); DocsPaVO.InstanceAccess.Metadata.UnitaOrganizzativa uoXML = convertiUO(unitaOrganizzativa); uoL.Add(uoXML); documento.SoggettoProduttore = new DocsPaVO.InstanceAccess.Metadata.SoggettoProduttore { Amministrazione = getInfoAmministrazione(ruolo.idAmministrazione), GerarchiaUO = new DocsPaVO.InstanceAccess.Metadata.GerarchiaUO { UnitaOrganizzativa = uoL.ToArray() }, Creatore = getCreatore(schDoc, ruolo) }; documento.IDdocumento = schDoc.systemId; documento.Oggetto = schDoc.oggetto.descrizione; documento.Tipo = convertiTipoPoto(schDoc); // documento.DataCreazione = Utils.formattaData(Utils.convertiData(schDoc.dataCreazione)); documento.DataCreazione = schDoc.dataCreazione; if (schDoc.privato != null && schDoc.privato.Equals("1")) { documento.LivelloRiservatezza = "privato"; } else { documento.LivelloRiservatezza = string.Empty; } if (instanceDoc.ENABLE && fileDoc != null) { documento.File = getFileDetail(fileDoc, objFileRequest, infoUtente); } documento.Registrazione = getRegistrazione(schDoc, ruolo); documento.ContestoArchivistico = getContestoArchivistico(schDoc, ruolo, infoUtente); if (schDoc.template != null) { DocsPaVO.InstanceAccess.Metadata.Tipologia t = new DocsPaVO.InstanceAccess.Metadata.Tipologia { NomeTipologia = schDoc.template.DESCRIZIONE, CampoTipologia = getCampiTipologia(schDoc.template) }; documento.Tipologia = t; } documento.Allegati = getAllegati(schDoc, instanceDoc, infoUtente); documento.TipoRichiesta = instanceDoc.TYPE_REQUEST; }
/// <summary> /// Operazione per l'inserimento di un file in una versione / allegato di un documento /// /// PreCondizione: /// la versione / allegato deve essere già stato creato come entità persistente /// /// Attributi dell'oggetto FileRequest già valorizzati in ingresso /// VersionId: ID della versione / allegato in docspa /// Version: 0 se allegato, > 0 se versione /// SubVersion: ! se allegato, stringa vuota se versione /// VersionLabel: A# se allegato (dove # è il num. dell'allegato, fino a 99) /// (es. A01, A02, A03, ecc.) /// 1, 2, 3, 4, ecc. se versione /// PostCondizioni: /// il file deve essere stato associato alla versione / allegato /// /// </summary> /// <param name="fileRequest"></param> /// <param name="fileDocumento"></param> /// <param name="estensione"></param> /// <param name="objSicurezza"></param> /// <returns></returns> public bool PutFile(DocsPaVO.documento.FileRequest fileRequest, DocsPaVO.documento.FileDocumento fileDocumento, string estensione) { logger.Info("BEGIN"); bool retValue = false; try { if (this.PitreDualFileWritingMode) { // E' attiva la modalità di scrittura dei file su entrambi i documentali retValue = this.DocumentManagerETDOCS.PutFile(fileRequest, fileDocumento, estensione); if (retValue) { // Inserimento del file in documentum retValue = this.DocumentManagerHERMES.PutFile(fileRequest, fileDocumento, estensione); //this.DocumentManagerDocumentum.PutFile(fileRequest, fileDocumento, estensione); } } else { // Inserimento del file in documentum retValue = this.DocumentManagerHERMES.PutFile(fileRequest, fileDocumento, estensione); if (retValue) { // Sovrascrittura: // L'aggiornamento dei metadati in etdocs inserisce in components il path completo // del file. Per PITRE non è possibile in quanto il file è nel repository DCTM // e pertanto non è possibile stabilirne il path. // Viene quindi aggiornato solo il nome del file + estensione. /* * string fileExtension = fileDocumento.estensioneFile; * if (string.IsNullOrEmpty(fileExtension)) * fileExtension = estensione; * * fileRequest.fileName = string.Format("{0}.{1}", fileRequest.versionId, fileExtension); * fileRequest.path = fileRequest.fileName; * fileRequest.fileSize = fileDocumento.content.Length.ToString(); * * // Aggiornamento dei metadati del file inserito nel documentale etdocs * ((DocsPaDocumentale_ETDOCS.Documentale.DocumentManager)this.DocumentManagerETDOCS).PutFileMetadata(fileRequest, fileDocumento, estensione); * * // DocsPaDB.Query_DocsPAWS.Documentale documentale = new DocsPaDB.Query_DocsPAWS.Documentale(); * // documentale.UpdateFileName(fileRequest.fileName, fileRequest.versionId); * * //this.SetFileAsInserted(fileRequest, fileDocumento.content); */ // Creazione nome file string fileName = string.Empty; if (!string.IsNullOrEmpty(fileRequest.fileName)) { fileName = fileRequest.fileName; string extensions = string.Empty; while (!string.IsNullOrEmpty(Path.GetExtension(fileName))) { extensions = Path.GetExtension(fileName) + extensions; fileName = Path.GetFileNameWithoutExtension(fileName); } fileName = string.Concat(fileRequest.versionId, extensions); } else { fileName = string.Format("{0}.{1}", fileRequest.versionId, estensione); } // Creazione path completo del file fileRequest.path = fileName; // Calcolo file size fileRequest.fileSize = fileDocumento.content.Length.ToString(); // Aggiornamento dei metadati del file inserito nel documentale etdocs ((DocsPaDocumentale_ETDOCS.Documentale.DocumentManager) this.DocumentManagerETDOCS).PutFileMetadata(fileRequest, fileDocumento, estensione); } } } catch (Exception ex) { logger.Debug(string.Format("Errore nel metodo PutFile: {0}", ex.Message)); retValue = false; } logger.Info("END"); return(retValue); }