/// <summary> /// Impostazione dell'url del webservice /// </summary> /// <param name="module"></param> /// <param name="serviceInstance"></param> private static void SetServiceInstanceUrl(string module, System.Web.Services.Protocols.SoapHttpClientProtocol serviceInstance) { string httpBindingClassName = serviceInstance.GetType().Name; string serviceName = httpBindingClassName.Remove(httpBindingClassName.IndexOf("SOAPHTTPBinding")); serviceInstance.Url = string.Concat(OCSConfigurations.GetServiceUrl(), string.Format("{0}/{1}SOAPHTTPPort", module, serviceName)); }
/// <summary> /// Reperimento credenziali OCS da superutente /// </summary> /// <returns></returns> public static UserCredentialsType getApplicationUserCredentials() { UserCredentialsType userCred = new UserCredentialsType(); userCred.userId = OCSConfigurations.GetSuperUser(); userCred.password = OCSConfigurations.GetSuperUserPwd(); return(userCred); }
/// <summary> /// Ricerca dell'id in ocs del documento in docspa /// </summary> /// <param name="idDocsPa"> /// Id del documento in docspa da cercare in ocs /// </param> /// <param name="documentCategoryName"> /// Categoria di appartenenza del documento /// </param> /// <param name="categoryFieldName"> /// Campo della categoria in base a cui cercare il documento /// </param> /// <param name="searchInCestino"> /// Se true, indica di cercare il documento nel cestino /// </param> /// <param name="ocsCredentials"></param> /// <returns> /// Corrispondente id in ocs del documento /// </returns> public static long getIdDocument(string idDocsPa, string documentCategoryName, string categoryFieldName, bool searchInCestino, UserCredentialsType ocsCredentials) { long idOCS = -1; //Reperimento idOCS in base ad una ricerca CorteContentServices.FilterSearchRequestType searchDocumentRequest = new CorteContentServices.FilterSearchRequestType(); searchDocumentRequest.userCredentials = ocsCredentials; searchDocumentRequest.filter = new CorteContentServices.FilterSearchType(); if (searchInCestino) { // Ricerca del documento nella cartella del cestino searchDocumentRequest.filter.folderPath = OCSConfigurations.GetPathCestino(); } else { // Ricerca del documento a partire dalla root path della libreria ocs corrente searchDocumentRequest.filter.folderPath = OCSConfigurations.GetDocRootFolder(); } searchDocumentRequest.filter.includeSubFolders = true; searchDocumentRequest.filter.includeSubFoldersSpecified = true; searchDocumentRequest.filter.count = 0; searchDocumentRequest.filter.countSpecified = true; searchDocumentRequest.filter.offset = 0; searchDocumentRequest.filter.offsetSpecified = true; searchDocumentRequest.filter.searchExpress = new DocsPaDocumentale_OCS.CorteContentServices.searchExpress(); searchDocumentRequest.filter.searchExpress.SearchExprType = new DocsPaDocumentale_OCS.CorteContentServices.SearchExprType(); string leftOpCr1 = string.Format("[{0}:{1}]", documentCategoryName, categoryFieldName); string operatCr1 = "EQUAL"; string rightOpCr1 = idDocsPa; searchDocumentRequest.filter.searchExpress.SearchExprType.leftOperand = leftOpCr1; searchDocumentRequest.filter.searchExpress.SearchExprType.@operator = operatCr1; searchDocumentRequest.filter.searchExpress.SearchExprType.rightOperand = rightOpCr1; searchDocumentRequest.filter.searchExpress.SearchExprType.sameLevelOperator = "AND"; searchDocumentRequest.filter.searchExpress.SearchExprType.SearchExprType1 = new DocsPaDocumentale_OCS.CorteContentServices.SearchExprType(); string operatCr2 = "HAS_CATEGORY"; string rightOpCr2 = string.Format("[{0}]", documentCategoryName); searchDocumentRequest.filter.searchExpress.SearchExprType.SearchExprType1.@operator = operatCr2; searchDocumentRequest.filter.searchExpress.SearchExprType.SearchExprType1.rightOperand = rightOpCr2; CorteContentServices.ItemSearchListResponseType listResult; DocumentManagementSOAPHTTPBinding wsDocument = OCSServiceFactory.GetDocumentServiceInstance <DocumentManagementSOAPHTTPBinding>(); listResult = wsDocument.SearchDocuments(searchDocumentRequest); OCSUtils.throwExceptionIfInvalidResult(listResult.result); // Reperimento itemId if (listResult.items != null && listResult.items.Length == 1) { idOCS = listResult.items[0].itemId; } return(idOCS); }
/// <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); }