Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="info"></param>
        /// <param name="infoUtente"></param>
        /// <returns></returns>
        public static long createFolder(CorteContentServices.InfoNameType info, DocsPaVO.utente.InfoUtente infoUtente)
        {
            CorteContentServices.FolderCreateType        folderCreate    = new CorteContentServices.FolderCreateType();
            CorteContentServices.FolderCreateRequestType folderCreateReq = new CorteContentServices.FolderCreateRequestType();

            CorteContentServices.ItemIdResponseType itemResp;
            folderCreate.info          = new DocsPaDocumentale_OCS.CorteContentServices.InfoType();
            folderCreate.info.name     = info.name;
            folderCreate.info.location = info.location;
            folderCreate.info.state    = DocsPaDocumentale_OCS.CorteContentServices.StateType.Undefined;
            folderCreate.info.author   = infoUtente.userId;
            //controllare il formato
            //PS: sarebbe meglio se il formato lo mettesse OCS quando non viene specificato
            folderCreate.info.creationDate = System.DateTime.Now;

            folderCreateReq.folder          = folderCreate;
            folderCreateReq.userCredentials = OCSServices.OCSUtils.getApplicationUserCredentials();

            FolderManagementSOAPHTTPBinding wsFolder = OCSServiceFactory.GetDocumentServiceInstance <FolderManagementSOAPHTTPBinding>();

            itemResp = wsFolder.CreateFolder(folderCreateReq);

            OCSUtils.throwExceptionIfInvalidResult(itemResp.result);

            return(itemResp.itemId);
        }
Exemple #2
0
        /// <summary>
        /// Accesso ad OCS usando il metodo GetDocumentByName
        /// </summary>
        /// <param name="path"></param>
        /// <param name="name"></param>
        /// <param name="ocsCredentials">Credenziali per effettuare l'operazione in ocs</param>
        /// <returns></returns>
        private static long getIdOCSByPath(string path, string name, UserCredentialsType ocsCredentials)
        {
            CorteContentServices.DocumentNameSearchRequestType nameReq = new CorteContentServices.DocumentNameSearchRequestType();
            CorteContentServices.ItemIdResponseType            itemIdResp;

            nameReq.userCredentials        = ocsCredentials;
            nameReq.document               = new DocsPaDocumentale_OCS.CorteContentServices.DocumentNameSearchType();
            nameReq.document.info          = new DocsPaDocumentale_OCS.CorteContentServices.InfoType();
            nameReq.document.info.location = path;
            nameReq.document.info.name     = name;

            DocumentManagementSOAPHTTPBinding wsDocument = OCSServiceFactory.GetDocumentServiceInstance <DocumentManagementSOAPHTTPBinding>();

            itemIdResp = wsDocument.GetDocumentByName(nameReq);

            OCSUtils.throwExceptionIfInvalidResult(itemIdResp.result);

            return(itemIdResp.itemId);
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="infoUtente"></param>
        /// <param name="create"></param>
        /// <returns></returns>
        public static long getFolderIdByName(string name, DocsPaVO.utente.InfoUtente infoUtente, bool create)
        {
            long folderId = -1;

            CorteContentServices.FolderNameSearchRequestType folderReq = new CorteContentServices.FolderNameSearchRequestType();
            folderReq.userCredentials = OCSServices.OCSUtils.getApplicationUserCredentials();
            folderReq.folder          = new DocsPaDocumentale_OCS.CorteContentServices.FolderNameSearchType();
            folderReq.folder.info     = new DocsPaDocumentale_OCS.CorteContentServices.InfoNameType();

            int pos = name.LastIndexOf("/");

            if (pos > -1)
            {
                folderReq.folder.info.location = name.Substring(0, pos);
                folderReq.folder.info.name     = name.Substring(pos + 1);
            }

            FolderManagementSOAPHTTPBinding wsFolder = OCSServiceFactory.GetDocumentServiceInstance <FolderManagementSOAPHTTPBinding>();

            CorteContentServices.ItemIdResponseType response = wsFolder.GetFolderByName(folderReq);

            // non posso lanciare l'eccezione perchè se il folder non esiste devo crearlo
            //OCSUtils.throwExceptionIfInvalidResult(response.result);

            if (OCSUtils.isValidServiceResult(response.result))
            {
                folderId = response.itemId;
            }
            else
            {
                // Se il folder non esiste bisogna crearlo (se richiesto)
                if (create && response.result.code == OCSResultTypeCodes.PATH_ITEM_NOT_VALID)
                {
                    folderId = createFolder(folderReq.folder.info, infoUtente);
                }
            }

            return(folderId);
        }
Exemple #4
0
        /// <summary>
        /// Rimozione delle ACL per un documento
        /// </summary>
        /// <param name="idDocsPa">ID del documento in docspa</param>
        /// <param name="idOcs">ID del documento in ocs</param>
        /// <param name="infoUtente">Credenziali docspa</param>
        /// <param name="ocsCredentials">Credenziali per effettuare l'operazione in ocs</param>
        /// <returns></returns>
        public static bool removeAclDocument(string idDocsPa, long idOcs, InfoUtente infoUtente, UserCredentialsType ocsCredentials)
        {
            CorteContentServices.GrantsType            grants;
            CorteContentServices.ItemGrantsRequestType itemGrantsRequest;
            CorteContentServices.ItemGrantsType        itemGrantsType;
            CorteContentServices.ResultType            resultGrants;

            grants = OCSServices.OCSUtils.getAclSecurity(idDocsPa);

            itemGrantsRequest = new CorteContentServices.ItemGrantsRequestType();
            itemGrantsRequest.userCredentials = ocsCredentials;
            itemGrantsType           = new CorteContentServices.ItemGrantsType();
            itemGrantsType.itemId    = idOcs;
            itemGrantsType.grants    = grants;
            itemGrantsRequest.grants = itemGrantsType;

            DocumentManagementSOAPHTTPBinding wsDocumentInstance = OCSServiceFactory.GetDocumentServiceInstance <DocumentManagementSOAPHTTPBinding>();

            resultGrants = wsDocumentInstance.RemoveDocumentGrants(itemGrantsRequest);

            OCSUtils.throwExceptionIfInvalidResult(resultGrants);

            return(true);
        }
Exemple #5
0
        /// <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);
        }