private static void addDocsInZip(List <ImportResult> results, ZipBuilder builder, string folder, InfoUtente infoUtente) { foreach (ImportResult temp in results) { try { List <BaseInfoDoc> infos = DocManager.GetBaseInfoForDocument(temp.DocNumber, null, null); BaseInfoDoc doc = infos[0]; FileRequest req = new FileRequest(); if (doc != null && !string.IsNullOrEmpty(doc.VersionLabel)) { logger.Debug("addDocsInZip GetBaseInfoForDocument VersionId " + doc.VersionLabel); } req.versionId = doc.VersionId; req.docNumber = doc.IdProfile; req.versionLabel = doc.VersionLabel; req.path = doc.Path; req.version = doc.VersionLabel; req.fileName = doc.FileName; FileDocumento fileDocumento = BusinessLogic.Documenti.FileManager.getFile(req, infoUtente); string extension = fileDocumento.fullName.Substring(fileDocumento.fullName.LastIndexOf(".") + 1); builder.AddEntry(temp.DocNumber + "." + extension, new string[] { folder }, fileDocumento.content); } catch (Exception e) { } } }
/// <summary> /// Caricamento delle informazioni sul documento /// </summary> private void LoadDocument() { // Il docNumber string docNumber = String.Empty; // L'idProfile string idProfile = String.Empty; // Il numero di versione string numVersion = String.Empty; // Lettura del docNumber if (!string.IsNullOrEmpty(Request.QueryString["docnumber"])) { docNumber = Request["docNumber"]; } // Lettura dell'idProfile if (!string.IsNullOrEmpty(Request.QueryString["idprofile"])) { idProfile = Request["idProfile"]; } // Lettura del numero di versione if (!String.IsNullOrEmpty(Request["numVersion"])) { numVersion = Request["numVersion"]; } // Se non si è in postback if (!this.IsPostBack) { // Caricamento dei dati da agganciare al data grid BaseInfoDoc[] docs = this.GetData(docNumber, idProfile, numVersion); // Bind di docs con il data grid this.Bind(docs); // Visualizzazione del documento richiesto o in sua assenza, del primo documento // disponibile BaseInfoDoc docToShow = docs.Where(e => e.DocNumber == docNumber).FirstOrDefault(); if (docToShow == null) { docToShow = docs[0]; } this.ShowDocument(docToShow.Description, docToShow.DocNumber, docToShow.VersionId, docToShow.VersionNumber.ToString(), docToShow.Path, docToShow.FileName, false, docToShow.IsProto); // Sbiancamento preliminare this.ClearGridItemSelections(); // Coloramento del primo elemento this.SelectGridItem(this.grdButtons.Items[0], true); } }
/// <summary> /// Reperimento del contentuto di un file dal repository Documentum /// </summary> /// <param name="docNumber"></param> /// <param name="version"></param> /// <param name="versionId"></param> /// <param name="versionLabel"></param> /// <returns></returns> public byte[] GetFile(string docNumber, string version, string versionId, string versionLabel) { logger.Info("BEGIN"); byte[] content = null; DocsPaDB.Query_DocsPAWS.Documenti documenti = new DocsPaDB.Query_DocsPAWS.Documenti(); List <BaseInfoDoc> listaSchedeDoc = documenti.GetBaseInfoForDocument(null, 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") { content = this.DocumentManagerSP.GetFile(docNumber, version, versionId, versionLabel); } else { // Il reperimento dei file viene dapprima effettuato dal documentale ETNOTEAM content = this.DocumentManagerETDOCS.GetFile(docNumber, version, versionId, versionLabel); } } catch (Exception ex) { logger.Debug("Errore nel reperimento del file nel documentale ETNOTEAM", ex); // Errore nel reperimento del file nel documentale ETNOTEAM content = null; } logger.Info("END"); return(content); }
/// <summary> /// Funzione per il recupero e la conversione del file a cui applicare il timestamp /// </summary> /// <param name="baseInfoDocs">Le informazioni di base sul documento</param> /// <returns>Il contenuto del file convertito</returns> private string GetFileForDocument(BaseInfoDoc baseInfoDocs) { // Il contenuto del file byte[] fileContent; // Il risultato dell'elaborazione string toReturn; // Se il documento non ha un file associato, viene lanciata // un'eccezione if (!baseInfoDocs.HaveFile) { throw new Exception("Il documento non ha un file associato"); } // Se il documento non è reperibile, viene sollevata un'eccezione //if (!File.Exists(baseInfoDocs.FileName)) // throw new Exception("Errore durante il reperimento del file"); // Recupero del contenuto del file try { /* * fileContent = FileManager.getInstance(Session.SessionID).GetFile( * this, * baseInfoDocs.VersionId, * baseInfoDocs.VersionNumber.ToString(), * baseInfoDocs.DocNumber, * baseInfoDocs.Path, * baseInfoDocs.FileName, * false).content; */ FileRequest fileRequest = new FileRequest { versionId = baseInfoDocs.VersionId, version = baseInfoDocs.VersionNumber.ToString(), docNumber = baseInfoDocs.DocNumber, path = baseInfoDocs.Path, fileName = baseInfoDocs.FileName }; fileContent = FileManager.getInstance(Session.SessionID).GetFile(this, fileRequest, false, true).content; } catch (Exception e) { throw new Exception("Errore durante il reperimento del file associato al documento."); } // Conversione del file toReturn = BitConverter.ToString(fileContent); toReturn = toReturn.Replace("-", ""); // Restituzione del risultato dell'operazione return(toReturn); }
protected string GetFileName(BaseInfoDoc baseInfoDoc) { if (String.IsNullOrEmpty(baseInfoDoc.FileName)) { return(String.Empty); } else { return(baseInfoDoc.FileName); } }
protected string GetPath(BaseInfoDoc baseInfoDoc) { if (String.IsNullOrEmpty(baseInfoDoc.Path)) { return(String.Empty); } else { return(baseInfoDoc.Path); } }
/// <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> /// Funzione per la validazione delle informazioni sul documento /// </summary> /// <param name="documentInfo">Le informazioni sul documento</param> /// <param name="message">L'eventuale messaggio di errore</param> /// <returns>Risultato della validazione</returns> private MassiveOperationReport.MassiveOperationResultEnum ValidateDocumentInformation( BaseInfoDoc documentInfo, out string message) { // Il risultato da restituire MassiveOperationReport.MassiveOperationResultEnum toReturn; // Inizializzazione del risultato e del messaggio toReturn = MassiveOperationReport.MassiveOperationResultEnum.OK; message = String.Empty; // Se non è stato acquisito un file per il documento, il risultato è negativo if (!documentInfo.HaveFile) { toReturn = MassiveOperationReport.MassiveOperationResultEnum.KO; message = "Nessun file acquisito per il documento."; } else // Altrimenti se il file è già un PDF il risultato è un AlreadyWorked if (Path.GetExtension(documentInfo.FileName).ToUpper().Equals(".PDF")) { toReturn = MassiveOperationReport.MassiveOperationResultEnum.AlreadyWorked; message = "Documento già convertito in PDF."; } // PALUMBO: Commentato in quanto se dualFileWriting = fals, non recupera i file. // Se il file risulta acquisito ma non è reperibile, il risultato è negativo //if (toReturn == MassiveOperationReport.MassiveOperationResultEnum.OK && // !File.Exists(documentInfo.FileName)) //{ // toReturn = MassiveOperationReport.MassiveOperationResultEnum.KO; // message = "Impossibile recuperare il file associato al documento."; //} // Restituzione del risultato return(toReturn); }
/// <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); }
protected string GetIsProto(BaseInfoDoc baseInfoDoc) { return(baseInfoDoc.IsProto.ToString()); }
protected string GetVersionNumber(BaseInfoDoc baseInfoDoc) { return(baseInfoDoc.VersionNumber.ToString()); }
protected string GetVersionId(BaseInfoDoc baseInfoDoc) { return(baseInfoDoc.VersionId); }
protected string GetDocNumber(BaseInfoDoc baseInfoDoc) { return(baseInfoDoc.DocNumber); }
protected string GetName(BaseInfoDoc baseInfoDoc) { return(baseInfoDoc.Name); }