/// <summary> /// /// </summary> /// <param name="request"></param> /// <returns></returns> public override DocsPaVO.Modelli.ModelResponse ProcessModel(DocsPaVO.Modelli.ModelRequest request) { DocsPaVO.Modelli.ModelResponse modelResponse = new DocsPaVO.Modelli.ModelResponse(); try { modelResponse.DocumentId = request.DocumentId; // Reperimento del motore word processor installato sul client per l'elaborazione del modello modelResponse.ProcessorInfo = ModelliManager.GetCurrentModelProcessor(request.UserInfo); if (modelResponse.ProcessorInfo == null) { throw new ApplicationException("In amministrazione non risulta impostato alcun software per generare il documento"); } // Reperimento scheda documento DocsPaVO.documento.SchedaDocumento document = this.GetDocument(request.UserInfo, request.DocumentId); // Reperimento del path del modello per la stampa della ricevuta di protocollo string modelPath = this.GetModelPath(document); // Reperimento del file template modello if (File.Exists(modelPath)) { modelResponse.DocumentModel.ModelType = BaseDocModelProcessor.MODEL_STAMPA_RICEVUTA; modelResponse.DocumentModel.File.FileName = Path.GetFileName(modelPath); modelResponse.DocumentModel.File.Content = File.ReadAllBytes(modelPath); modelResponse.DocumentModel.KeyValuePairs = this.GetModelKeyValuePairs(request.UserInfo, document); } else { throw new ApplicationException("File modello inesistente"); } } catch (Exception ex) { modelResponse = new DocsPaVO.Modelli.ModelResponse(); modelResponse.Exception = ex.Message; logger.Debug(string.Format("Errore nel reperimento dei dati del modello: {0}", ex.Message)); } return(modelResponse); }
/// <summary> /// Elaborazione dei modelli documento /// </summary> /// <param name="request"></param> /// <returns></returns> public override ModelResponse ProcessModel(ModelRequest request) { DocsPaVO.Modelli.ModelResponse modelResponse = new DocsPaVO.Modelli.ModelResponse(); try { modelResponse.DocumentId = request.DocumentId; // Reperimento del motore word processor installato sul client per l'elaborazione del modello modelResponse.ProcessorInfo = ModelliManager.GetCurrentModelProcessor(request.UserInfo); if (modelResponse.ProcessorInfo == null) { throw new ApplicationException("In amministrazione non risulta impostato alcun software per generare il documento"); } // Reperimento scheda documento DocsPaVO.documento.SchedaDocumento document = GetDocument(request.UserInfo, request.DocumentId); string modelPath = string.Empty; if (document.documentoPrincipale != null && request.ModelType.StartsWith(BaseDocModelProcessor.MODEL_ATTATCHMENT)) { request.ModelType = request.ModelType.Substring(1, 1); // Caricamento documento allegato DocsPaVO.documento.SchedaDocumento attatchment = BusinessLogic.Documenti.DocManager.getDettaglio(request.UserInfo, document.documentoPrincipale.idProfile, document.documentoPrincipale.docNumber); // Reperimento path del modello allegato modelPath = this.GetAttatchmentModelPath(request.ModelType, attatchment.docNumber); // Caricamento del modello dell'allegato modelResponse.DocumentModel = this.LoadModel(request, modelPath, attatchment); } else { // Reperimento path del modello modelPath = this.GetModelPath(request.ModelType, document.docNumber); // Se è richiesto il modello per la versione 2 ma non è disponibile, // viene forzato l'utilizzo del modello 1 if (request.ModelType == BaseDocModelProcessor.MODEL_VERSION_2 && string.IsNullOrEmpty(modelPath)) { request.ModelType = BaseDocModelProcessor.MODEL_VERSION_1; modelPath = this.GetModelPath(request.ModelType, document.docNumber); } // Caricamento del modello del documento modelResponse.DocumentModel = this.LoadModel(request, modelPath, document); if (request.ModelType == BaseDocModelProcessor.MODEL_VERSION_2) { // Recupero del contenuto della versione corrente del documento DocsPaVO.documento.FileRequest previousVersion = (DocsPaVO.documento.FileRequest)document.documenti[0]; DocsPaVO.documento.FileDocumento previousVersionFile = BusinessLogic.Documenti.FileManager.getFile(previousVersion, request.UserInfo); if (previousVersionFile != null) { // Il contenuto del file della versione corrente del documento // viene inserito nella proprietà contentreplacement // per essere inserito nel contenuto del nuovo documento da elaborare DocsPaVO.Modelli.IncludeSection section = new DocsPaVO.Modelli.IncludeSection(); section.Begin = "Start_Body"; section.End = "End_Body"; section.File.FileName = Path.GetFileName(previousVersion.fileName); section.File.Content = previousVersionFile.content; modelResponse.IncludeSections = new DocsPaVO.Modelli.IncludeSection[1] { section }; } } } } catch (Exception ex) { modelResponse = new DocsPaVO.Modelli.ModelResponse(); modelResponse.Exception = ex.Message; logger.Debug(string.Format("Errore nel reperimento dei dati del modello: {0}", ex.Message)); } return(modelResponse); }