/// <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); }
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 static FirmaDigitale extractFirmaDigitale(DocsPaVO.documento.FileDocumento fileDoc) { VerifySignature verifySignature = new VerifySignature(); string inputDirectory = verifySignature.GetPKCS7InputDirectory(); // Creazione cartella di appoggio nel caso non esista if (!System.IO.Directory.Exists(inputDirectory)) { System.IO.Directory.CreateDirectory(inputDirectory); } string inputFile = string.Concat(inputDirectory, fileDoc.name); // Copia del file firmato dalla cartella del documentale // alla cartella di input utilizzata dal ws della verifica CopySignedFileToInputFolder(fileDoc, inputFile); fileDoc.signatureResult = verifySignature.Verify(fileDoc.name); try { // Rimozione del file firmato dalla cartella di input System.IO.File.Delete(inputFile); } catch { } if (fileDoc.signatureResult == null) { return(null); } FirmaDigitale fd = null; if (fileDoc.signatureResult.PKCS7Documents != null) { fd = new FirmaDigitale(); foreach (PKCS7Document p7m in fileDoc.signatureResult.PKCS7Documents) { if (p7m.SignersInfo != null) { DocsPaVO.documento.SignerInfo si = p7m.SignersInfo.FirstOrDefault(); CnipaParser cp = new CnipaParser(); cp.ParseCNIPASubjectInfo(ref si.SubjectInfo, si.CertificateInfo.SubjectName); fd.Certificato = String.Format("{0} {1} {2}", "<![CDATA[", Utils.SerializeObject <CertificateInfo>(si.CertificateInfo, true), "]]>"); fd.DatiFirma = String.Format("{0} {1} {2}", "<![CDATA[", Utils.SerializeObject <SubjectInfo>(si.SubjectInfo, true), "]]>"); fd.Titolare = new Titolare { CodiceFiscale = si.SubjectInfo.CodiceFiscale, Nome = si.SubjectInfo.Nome, Cognome = si.SubjectInfo.Cognome }; } } } return(fd); }
/// <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); }
private static void CopySignedFileToInputFolder(DocsPaVO.documento.FileDocumento fileDoc, string inputFile) { System.IO.FileStream stream = new System.IO.FileStream(inputFile, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write); stream.Write(fileDoc.content, 0, fileDoc.content.Length); stream.Flush(); stream.Close(); stream = null; }
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> /// 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); }
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); }
private static FileDocumento CreateFileDocumentoRTF(Byte[] fileContent) { FileDocumento fileDoc = new DocsPaVO.documento.FileDocumento(); fileDoc.name = "StampaFascetteFascicolo.RTF"; fileDoc.path = ""; fileDoc.fullName = '\u005C'.ToString() + fileDoc.name; fileDoc.length = (int)fileContent.Length; fileDoc.content = fileContent; fileDoc.contentType = "application/rtf"; return(fileDoc); }
public void Import(FileDocumento fd) { this.cartaceo = fd.cartaceo; this.name = fd.name; this.path = fd.path; this.fullName = fd.fullName; this.content = fd.content; this.length = fd.length; this.contentType = fd.contentType; this.estensioneFile = fd.estensioneFile; this.nomeOriginale = fd.nomeOriginale; this.LabelPdf = fd.LabelPdf; this.signatureResult = fd.signatureResult; this.msgErr = fd.msgErr; this.timestampResult = fd.timestampResult; this.bypassFileContentValidation = fd.bypassFileContentValidation; }
/// <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> /// 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> /// /// </summary> /// <param name="numDocumento"></param> /// <param name="infoUtente"></param> /// <returns></returns> public static DocsPaVO.ExportFascicolo.ContentDocumento GetFileDocumento(DocsPaVO.utente.InfoUtente infoUtente, string numDocumento) { //gestione TSR if (numDocumento.StartsWith("TSR_")) { //reperisco il docnumber string docNum = numDocumento.Split('_')[1]; string tsrBase64 = getTimeStampForDocNumber(infoUtente, docNum); DocsPaVO.documento.FileDocumento fdTsr = GetFile(infoUtente, docNum); if (!String.IsNullOrEmpty(tsrBase64)) { return(new DocsPaVO.ExportFascicolo.ContentDocumento { FileContent = Convert.FromBase64String(tsrBase64), MimeType = "application/timestamp-reply", FileExtension = System.IO.Path.GetExtension(fdTsr.name) + ".TSR" }); } } // Download del file associato al documento DocsPaVO.documento.FileDocumento fileDocumento = GetFile(infoUtente, numDocumento); if (fileDocumento != null) { return(new DocsPaVO.ExportFascicolo.ContentDocumento { FileContent = fileDocumento.content, MimeType = fileDocumento.contentType, FileExtension = System.IO.Path.GetExtension(fileDocumento.name) }); } else { return(null); } }
/// <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); }
/// <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); }
/// <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) { return(this.DocumentManagerOCS.GetFile(ref fileDocumento, ref fileRequest)); }
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> /// 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); }
public bool ManageAttachXML(DocsPaVO.documento.SchedaDocumento schedaDocOriginale, DocsPaVO.documento.SchedaDocumento schedaDocCopiato, string IdRuoloMittenteFisico, DocsPaVO.utente.InfoUtente infoUtenteInterop) { //****************************************************************************************************************// // Modifica Evolutiva di Giordano Iacozzilli Data: 27/04/2012 // // La presidenza del Consiflio dei Ministri richiede la possibilità di inviare via Interoperabilità interna, // al Registro dell'Ufficio UBRRAC un file Xml contenente un insieme di dati integrativi associati ad alcune tipologie // di documenti prodotti dai centri di spesa per una successiva elaboraizone dal sistema OpenDGov. // //Workflow: // 1) Controllo presenza su db del codice FE_ATTACH_XML nella Config Globali // 2) Se il controllo è ok, verifico che il tipo doc sia compreso nella lista dei tipi ammessi(GET DEI TIPI DOC COL PIPE DAL DB). // 3) Verifico che il mio Ruolo abbia la visibilità su tutti i campi, altrimenti nada. // 4) Creo L'xml e lo allego alla scheda Doc // //****************************************************************************************************************// //Doppio controllo, interop Semplificata e Xml Attach. if (System.Configuration.ConfigurationManager.AppSettings["INTEROP_INT_NO_MAIL"] != null && System.Configuration.ConfigurationManager.AppSettings["INTEROP_INT_NO_MAIL"].ToString() != "0") { //1) Controllo presenza su db del codice FE_ATTACH_XML nella Config Globali if (GET_XML_ATTACH()) { //Get Template. DocsPaVO.ProfilazioneDinamica.Templates template = (schedaDocOriginale.template); string err = string.Empty; //verifico che il tipo doc sia compreso nella lista dei tipi ammessi if (template != null && GET_TIPI_ATTI_CUSTOM().Contains(ClearString(GetDescrTipoAtto(template.ID_TIPO_ATTO, infoUtenteInterop.idAmministrazione)))) { DocsPaVO.ProfilazioneDinamica.AssDocFascRuoli _ass = new AssDocFascRuoli(); //Verifico che il mio Ruolo abbia la visibilità su tutti i campi, altrimenti nada. int _totCampi = template.ELENCO_OGGETTI.Count; int _ContCampi = 0; for (int i = 0; i < template.ELENCO_OGGETTI.Count; i++) { OggettoCustom oggettoCustom = (OggettoCustom)template.ELENCO_OGGETTI[i]; // visibilità. _ass = ProfilazioneDinamica.ProfilazioneDocumenti.getDirittiCampoTipologiaDoc(IdRuoloMittenteFisico, template.SYSTEM_ID.ToString(), oggettoCustom.SYSTEM_ID.ToString()); if (_ass.VIS_OGG_CUSTOM == "1") { _ContCampi = _ContCampi + 1; } } //Verifico che il mio Ruolo abbia la visibilità su tutti i campi if (_ContCampi == _totCampi) { if (schedaDocCopiato.documenti != null && schedaDocCopiato.documenti[0] != null) { try { Dictionary <string, string> _dict = new Dictionary <string, string>(); foreach (OggettoCustom oggettoCustom in template.ELENCO_OGGETTI) { _dict.Add(oggettoCustom.DESCRIZIONE, oggettoCustom.VALORE_DATABASE); } //Creo L'xml e lo allego alla scheda Doc XmlDocument xDocDaAllegare = new XmlDocument(); xDocDaAllegare = CreateXmlToAttach(_dict, schedaDocCopiato, GetDescrTipoAtto(template.ID_TIPO_ATTO, infoUtenteInterop.idAmministrazione)); DocsPaVO.documento.Allegato allegato = null; //Add Allegato: allegato = new DocsPaVO.documento.Allegato(); allegato.descrizione = GetDescrTipoAtto(template.ID_TIPO_ATTO, infoUtenteInterop.idAmministrazione) + "_XML"; allegato.numeroPagine = 1; allegato.docNumber = schedaDocCopiato.docNumber; allegato.version = "0"; allegato.position = (schedaDocOriginale.allegati.Count + 1); allegato = BusinessLogic.Documenti.AllegatiManager.aggiungiAllegato(infoUtenteInterop, allegato); //Add del File xml come filedocumento: DocsPaVO.documento.FileDocumento fdAllNew = new DocsPaVO.documento.FileDocumento(); fdAllNew.content = Encoding.UTF8.GetBytes(xDocDaAllegare.OuterXml); fdAllNew.length = Encoding.UTF8.GetBytes(xDocDaAllegare.OuterXml).Length; fdAllNew.name = GetDescrTipoAtto(template.ID_TIPO_ATTO, infoUtenteInterop.idAmministrazione) + "_XML" + ".xml"; fdAllNew.fullName = fdAllNew.name; fdAllNew.contentType = "text/xml"; DocsPaVO.documento.FileRequest fr = (DocsPaVO.documento.FileRequest)allegato; if (!BusinessLogic.Documenti.FileManager.putFile(ref fr, fdAllNew, infoUtenteInterop, out err)) { throw new Exception(err); } } catch (Exception ex) { err = ex.Message; throw ex; } } else { return(false); } } else { return(false); } } else { return(false); } } else { return(false); } return(true); } else { return(false); } }
public bool ManageAttachXML_Suap(ref DocsPaVO.documento.SchedaDocumento schedaDocOriginale, DocsPaVO.utente.InfoUtente infoUtenteInterop, string mailFrom) { if (schedaDocOriginale.template == null) { return(false); } if (schedaDocOriginale.template.DESCRIZIONE.ToUpper() != "ENTESUAP") { return(false); } XmlParsing.suap.SuapManager sm = new XmlParsing.suap.SuapManager("ENTESUAP"); //refresh DocsPaVO.documento.SchedaDocumento schedaDoc = BusinessLogic.Documenti.DocManager.getDettaglio(infoUtenteInterop, schedaDocOriginale.docNumber, schedaDocOriginale.docNumber); string xmlResult = sm.ExportEnteSuapXML(infoUtenteInterop, schedaDoc, mailFrom); if (String.IsNullOrEmpty(xmlResult)) { return(false); } Allegato allEntesuap = null; foreach (Allegato all in schedaDoc.allegati) { string originalName = BusinessLogic.Documenti.FileManager.getOriginalFileName(infoUtenteInterop, all); if ((originalName != null) && (originalName.ToLowerInvariant().Equals("entesuap.xml"))) { allEntesuap = all; break; } } //Add del File xml come filedocumento: DocsPaVO.documento.FileDocumento fdAllNew = new DocsPaVO.documento.FileDocumento(); fdAllNew.content = Encoding.UTF8.GetBytes(xmlResult); fdAllNew.length = fdAllNew.content.Length; fdAllNew.name = "ENTESUAP.XML"; fdAllNew.fullName = fdAllNew.name; fdAllNew.contentType = "text/xml"; string err; if (allEntesuap != null) { FileDocumento fd = BusinessLogic.Documenti.FileManager.getFile(allEntesuap, infoUtenteInterop); string xmlAll = System.Text.ASCIIEncoding.ASCII.GetString(fd.content); // if (XmlParsing.suap.SuapManager.compareEnteSuapXml(xmlAll, xmlResult)) { return(true); } else { FileRequest fileReq = new Documento(); fileReq.docNumber = allEntesuap.docNumber; fileReq.descrizione = "Versione creata per modifiche apportate ai dati contenuti nel file ENTESUAP.xml"; DocsPaVO.documento.FileRequest fr = VersioniManager.addVersion(fileReq, infoUtenteInterop, false); if (!BusinessLogic.Documenti.FileManager.putFile(ref fr, fdAllNew, infoUtenteInterop, out err)) { throw new Exception(err); } else { SchedaDocumento sdNew = BusinessLogic.Documenti.DocManager.getDettaglio(infoUtenteInterop, schedaDoc.docNumber, schedaDoc.docNumber); schedaDocOriginale.allegati = sdNew.allegati; return(true); } } } else { DocsPaVO.documento.Allegato allegato = new DocsPaVO.documento.Allegato(); allegato.descrizione = "ENTESUAP.XML"; allegato.numeroPagine = 1; allegato.docNumber = schedaDoc.docNumber; allegato.version = "0"; allegato = BusinessLogic.Documenti.AllegatiManager.aggiungiAllegato(infoUtenteInterop, allegato); DocsPaVO.documento.FileRequest fr = (DocsPaVO.documento.FileRequest)allegato; if (!BusinessLogic.Documenti.FileManager.putFile(ref fr, fdAllNew, infoUtenteInterop, out err)) { throw new Exception(err); } else { SchedaDocumento sdNew = BusinessLogic.Documenti.DocManager.getDettaglio(infoUtenteInterop, schedaDoc.docNumber, schedaDoc.docNumber); schedaDocOriginale.allegati = sdNew.allegati; return(true); } } //presume insuccesso (mai na gioa).. //return false; }
private static string GetMetaInfoDocumentoOFN(DocsPaVO.utente.InfoUtente infoUtente, DocsPaVO.ExportFascicolo.MetaInfoFascicolo fascicolo, ref string report, string path) { int iterator = 0; for (iterator = 0; iterator < fascicolo.Documenti.Length; iterator++) { DocsPaVO.ExportFascicolo.MetaInfoDocumento documentoNext = null; DocsPaVO.ExportFascicolo.MetaInfoDocumento documento = fascicolo.Documenti[iterator]; if ((iterator + 1) < fascicolo.Documenti.Length) { documentoNext = fascicolo.Documenti[iterator + 1]; } if (!documento.Id.StartsWith("OFN-FASCID:")) { string ofn = string.Empty; string ext = string.Empty; string versID = BusinessLogic.Documenti.VersioniManager.getLatestVersionID(documento.Id, infoUtente); DocsPaVO.documento.FileRequest fileRq = new DocsPaVO.documento.FileRequest { docNumber = documento.Id, versionId = versID }; ofn = BusinessLogic.Documenti.FileManager.getOriginalFileName(infoUtente, fileRq); DocsPaVO.documento.FileDocumento fd = GetFile(infoUtente, documento.Id); //prendiamo l'impronta per sapere se è aquisito string impronta = null;; DocsPaDB.Query_DocsPAWS.Documenti doc = new DocsPaDB.Query_DocsPAWS.Documenti(); doc.GetImpronta(out impronta, versID, documento.Id); if (String.IsNullOrEmpty(impronta)) //non aquisito { continue; } string filepath = BusinessLogic.Documenti.FileManager.getCurrentVersionFilePath(infoUtente, documento.Id); if (String.IsNullOrEmpty(filepath)) //non aquisito { continue; } ext = System.IO.Path.GetExtension(filepath); if (string.IsNullOrEmpty(ofn)) { ofn = documento.Nome; } string nomeFile = path + "\\" + documento.Nome + ext; if (nomeFile.StartsWith("\\")) { nomeFile = nomeFile.Substring(1); } string nomeOri = path + "\\" + ofn; if (nomeOri.StartsWith("\\")) { nomeOri = nomeOri.Substring(1); } if (documento.IsAllegato) { report += "<li>"; } report += string.Format("<a href=\"{0}\" TITLE={2}>{1}</a> <br/>\r\n", nomeFile, nomeOri, documento.Nome); if (documento.IsAllegato) { report += "</li>"; } //Gestione indentatura per il file html if (documentoNext != null) { if (documento.IsAllegato) { if (!documentoNext.IsAllegato) { report += "</ul>"; } } else { if (documentoNext.IsAllegato) { report += "<ul>"; } } } else { if (documento.IsAllegato) { report += "</ul>"; } } } } foreach (DocsPaVO.ExportFascicolo.MetaInfoFascicolo sottoFascicoli in fascicolo.Fascicoli) { string nomesottofascicolo = path + "\\" + sottoFascicoli.Nome; if (nomesottofascicolo.StartsWith("\\")) { nomesottofascicolo = nomesottofascicolo.Substring(1); } report += "<p><h2>Sottofascicolo " + nomesottofascicolo + "</h2></p>"; GetMetaInfoDocumentoOFN(infoUtente, sottoFascicoli, ref report, path + "\\" + sottoFascicoli.Nome); } return(report); }