/// <summary> /// Upload del documento /// </summary> /// <param name="fileDoc"></param> /// <param name="errorMessage"></param> /// <returns></returns> public bool Upload(SAAdminTool.DocsPaWR.FileDocumento fileDoc, bool conversionePDFServer, out string errorMessage) { bool retValue = false; errorMessage = string.Empty; try { ProtocollazioneIngressoLog.WriteLogEntry( string.Format("UploadDocumento (FileName: {0} - Dim: {1}", fileDoc.name, fileDoc.content.Length.ToString())); } catch { } SAAdminTool.DocsPaWR.FileRequest fileReq = this.GetFileRequest(fileDoc.name); // Booleano utilizzato per indicare se è necessario convertire in PDF in modalità Asincrona bool convertAsync = false; if (fileReq != null) { fileReq.cartaceo = fileDoc.cartaceo; ProtocollazioneIngresso.Login.LoginMng loginMng = new ProtocollazioneIngresso.Login.LoginMng(this._page); SAAdminTool.DocsPaWR.DocsPaWebService ws = new SAAdminTool.DocsPaWR.DocsPaWebService(); ws.Timeout = System.Threading.Timeout.Infinite; // Se è attiva la conversione PDF sincrona, si prova a convertire il file facendo vincere lei // se la conversione va a buon fine, viene associato il file pdf al documento altrimenti viene // acquisito il TIF e si prova ad eseguire la conversione asincrona if (Utils.IsEbabledConversionePdfLatoServerSincrona().ToLower() == "true") { FileDocumento convertedDoc = ws.GeneratePDFInSyncMod(fileDoc); if (convertedDoc == null) { convertAsync = true; } if (convertedDoc != null && convertedDoc.content.Length > 0) { fileDoc = convertedDoc; } } retValue = ws.DocumentoPutFileNoException(ref fileReq, fileDoc, loginMng.GetInfoUtente(), out errorMessage); } //Se abilitata la conversione lato server ed è necessario effettuare la conversione asincrona, // chiamo il webmethod che mette in coda il file da convertire if (retValue && conversionePDFServer && convertAsync) { SAAdminTool.DocsPaWR.SchedaDocumento documento = null; if (fileReq.GetType() == typeof(SAAdminTool.DocsPaWR.Allegato)) { // Il documento acquisito è un allegato: reperimento della scheda documento documento = DocumentManager.getDettaglioDocumento(this._page, fileReq.docNumber, fileReq.docNumber); } else { ProtocollazioneIngresso.Protocollo.ProtocolloMng protocolloMng = new ProtocollazioneIngresso.Protocollo.ProtocolloMng(this._page); documento = protocolloMng.GetDocumentoCorrente(); } FileManager.EnqueueServerPdfConversion(this._page, UserManager.getInfoUtente(this._page), fileDoc.content, fileDoc.name, documento); } return(retValue); }
/// <summary> /// Inserimento del file request nella scheda documento /// </summary> /// <param name="schedaDocumento"></param> /// <param name="fileRequest"></param> private void AppendFileRequestDocumenti(SAAdminTool.DocsPaWR.SchedaDocumento schedaDocumento, SAAdminTool.DocsPaWR.FileRequest fileRequest) { ArrayList list = new ArrayList(schedaDocumento.documenti); list.Add(fileRequest); schedaDocumento.documenti = null; schedaDocumento.documenti = new SAAdminTool.DocsPaWR.Documento[list.Count]; list.CopyTo(schedaDocumento.documenti); }