/// <summary> /// Per reperire la locazione del documento /// </summary> /// <param name="schedaDoc"></param> /// <param name="objSicurezza"></param> /// <param name="isNewDoc"></param> /// <returns></returns> public static string getDocumentLocation(SchedaDocumento schedaDoc, DocsPaVO.utente.InfoUtente objSicurezza, bool isNewDoc) { string result = null; try { if (schedaDoc != null) { //legge il record da DPA_CORR_GLOBALI in JOIN con DPA_AMMINISTRA DocsPaDB.Query_DocsPAWS.Documentale documentale = new DocsPaDB.Query_DocsPAWS.Documentale(); System.Data.DataSet corrispondente; if (!documentale.DOC_GetCorrByIdPeople(objSicurezza.idPeople, out corrispondente)) { logger.Debug("Errore nella lettura del corrispondente relativo al documento"); throw new Exception(); } //legge l'amministrazione string amministrazione = DocsPaUtils.Data.DataReaderHelper.GetValue <string>(corrispondente.Tables[0].Rows[0], "VAR_CODICE_AMM", false); string codiceUO = string.Empty; if (schedaDoc.creatoreDocumento != null && schedaDoc.creatoreDocumento.uo_codiceCorrGlobali != null) { codiceUO = schedaDoc.creatoreDocumento.uo_codiceCorrGlobali; } else { codiceUO = DocsPaServices.DocsPaQueryHelper.getCodiceUO(schedaDoc.docNumber); if ((codiceUO == null || codiceUO.Equals("")) && isNewDoc) { //legge l'id della uo di appartenenza del gruppo string id = documentale.DOC_GetIdUoBySystemId(objSicurezza.idGruppo); if (string.IsNullOrEmpty(id)) { logger.Debug("Errore nella lettura del gruppo relativo al documento"); throw new Exception(); } //recupera il nome della UO codiceUO = documentale.DOC_GetUoById(id); } } //legge la tabella profile System.Data.DataSet documento; if (!documentale.DOC_GetDocByDocNumber(schedaDoc.docNumber, out documento)) { logger.Debug("Errore nella lettura del documento: " + schedaDoc.docNumber); throw new Exception(); } //legge l'anno di creazione del documento string anno = System.DateTime.Parse(documento.Tables[0].Rows[0]["CREATION_DATE"].ToString()).Year.ToString(); //verifica se il documento è protocollato string tipoProtocollo; tipoProtocollo = documento.Tables[0].Rows[0]["CHA_TIPO_PROTO"].ToString().ToUpper(); string registro = ""; string arrivoPartenza = ""; if (schedaDoc.tipoProto == "A" || schedaDoc.tipoProto == "P" || schedaDoc.tipoProto == "I" || schedaDoc.tipoProto == "R") { //crea il path nel caso di documento protocollato -> AMMINISTRAZIONE + REGISTRO + ANNO + [COD_UO] + [ARRIVO|PARTENZA] //legge il registro della protocollazione //controllo che l'idRegistro esiste string idRegistro = ""; if (schedaDoc.registro != null && !String.IsNullOrEmpty(schedaDoc.registro.systemId)) { idRegistro = schedaDoc.registro.systemId; } if (String.IsNullOrEmpty(idRegistro)) { documento.Tables[0].Rows[0]["ID_REGISTRO"].ToString(); } registro = documentale.DOC_GetRegistroById(idRegistro); if (registro == null) { logger.Debug("registro non trovato"); registro = ""; } if (schedaDoc.tipoProto.Equals("A")) { arrivoPartenza = "Arrivo"; } else if (schedaDoc.tipoProto.Equals("P")) { arrivoPartenza = "Partenza"; } else if (schedaDoc.tipoProto.Equals("I")) { arrivoPartenza = "Interno"; } else if (schedaDoc.tipoProto.Equals("R")) { arrivoPartenza = "StampaRegistro"; } } string filePath = OCSConfigurations.GetDocPathPattern(); filePath = filePath.Replace("AMMINISTRAZIONE", amministrazione); filePath = filePath.Replace("REGISTRO", registro); filePath = filePath.Replace("ANNO", anno); filePath = filePath.Replace("ARRIVO_PARTENZA", arrivoPartenza); filePath = filePath.Replace("UFFICIO", codiceUO); filePath = filePath.Replace("UTENTE", objSicurezza.userId); filePath = filePath.Replace("//", "/"); if (filePath.EndsWith("/")) { filePath = filePath.Remove(filePath.Length - 1, 1); } //verifica se la directory esiste string pathCompleto = OCSConfigurations.GetDocRootFolder() + "/" + filePath; pathCompleto = pathCompleto.Replace("//", "/"); //restituisce la directory result = pathCompleto; } } catch (Exception e) { logger.Error("Errore creazione path documentale per documento: " + schedaDoc.docNumber, e); result = null; } return(result); }