/// <summary> /// Ricerca fulltext nell'oggetto document /// /// nb: da fare anche ricerca allegati /// </summary> /// <param name="context"></param> /// <returns></returns> public ArrayList FullTextSearch(ref FullTextSearchContext context) { ArrayList result = new ArrayList(); try { List <string> fullTextResult = null; if (context.SearchResultList != null && context.SearchResultList.Length > 0) { // Ricerca già effettuata, reperimento dall'oggetto di contesto // dei risultati precedenti evitando così una dispendiosa // chiamata al sistema documentale fullTextResult = new List <string>(context.SearchResultList); } else { StructuredQuery strQuery = new StructuredQuery(); strQuery.AddRepository(DctmConfigurations.GetRepositoryName()); strQuery.ObjectType = ObjectTypes.DOCUMENTO; strQuery.IsDatabaseSearch = false; strQuery.IsIncludeAllVersions = false; strQuery.IsIncludeHidden = false; // Inserisce nella ricerca il solo cabinet dell'amministrazione RepositoryScope repositoryScope = new RepositoryScope(); repositoryScope.RepositoryName = DctmConfigurations.GetRepositoryName(); repositoryScope.LocationPath = DocsPaAdminCabinet.getRootAmministrazione(this.InfoUtente); repositoryScope.IsDescend = true; strQuery.Scopes.Add(repositoryScope); ExpressionSet set = new ExpressionSet(); set.AddExpression(new FullTextExpression(context.TextToSearch)); strQuery.RootExpressionSet = set; // Query execution int startIndex = (context.RequestedPageNumber * PAGE_SIZE) - PAGE_SIZE; int maxResults = this.GetMaxRowCount(); QueryExecution queryExec = new QueryExecution(startIndex, maxResults, maxResults); ISearchService searchService = DctmServiceFactory.GetServiceInstance <ISearchService>(this.InfoUtente.dst); QueryResult queryResult = searchService.Execute(strQuery, queryExec, null); QueryStatus queryStatus = queryResult.QueryStatus; RepositoryStatusInfo repStatusInfo = queryResult.QueryStatus.RepositoryStatusInfos[0]; if (repStatusInfo.Status == Status.FAILURE) { throw new ApplicationException("QueryResult: Status.FAILURE"); } fullTextResult = new List <string>(); foreach (DataObject dataObject in queryResult.DataObjects) { // Reperimento docnumber string docNumber = dataObject.Properties.Get(TypeDocumento.DOC_NUMBER).GetValueAsString(); if (!fullTextResult.Contains(docNumber)) // Eliminazione dei risultati duplicati { fullTextResult.Add(docNumber); } } context.SearchResultList = fullTextResult.ToArray(); context.TotalPageNumber = (fullTextResult.Count / PAGE_SIZE); context.TotalRecordCount = fullTextResult.Count; } // Paginazione dei risultati if (fullTextResult != null && fullTextResult.Count > 0) { int startIndex = (context.RequestedPageNumber * PAGE_SIZE) - PAGE_SIZE; int count = PAGE_SIZE; if (fullTextResult.Count < count) { count = fullTextResult.Count; } List <string> pageContent = fullTextResult.GetRange(startIndex, count); result = this.GetDocuments(pageContent.ToArray(), InfoUtente); } } catch (Exception ex) { result.Clear(); logger.Debug(string.Format("Errore in Documentum.FullTextSearch:\n{0}", ex.ToString())); } return(result); }
/// <summary> /// Creazione ObjectPath relativamente al cabinet che rappresenta l'amministrazione di docspa in documentum /// </summary> /// <param name="info"></param> /// <returns></returns> protected ObjectPath GetCabinetPath(InfoAmministrazione info) { return(new ObjectPath(string.Format("{0}/", DocsPaAdminCabinet.getRootAmministrazione(info.Codice)))); }
/// <summary> /// Inserimento o aggiornamento dei metadati generali relativi /// all’intera struttura di classificazione dei documenti /// </summary> /// <param name="titolario"></param> /// <returns></returns> public bool SaveTitolario(OrgTitolario titolario) { bool retValue = false; try { //titolario.ID viene SEMPRE valorizzato da ETDOCS; se così non è --> ERRORE if (string.IsNullOrEmpty(titolario.ID)) { logger.Debug("Errore passaggio dati da ETDOCS: ID Titolario mancante"); } else { // Reperimento istanza objectservice IObjectService objSrvc = GetObjectServiceInstance(); DataObject dataObject = new DataObject(); dataObject.Type = ObjectTypes.TITOLARIO; // Reperimento oggetto identity per il titolario corrente ObjectIdentity titolarioIdentity = Dfs4DocsPa.getTitolarioIdentity(titolario.ID); IQueryService querySrvc = this.GetQueryServiceInstance(); // Verifica se il titolario è già esistente bool insertMode = (!Dfs4DocsPa.containsTitolario(titolario.ID, querySrvc)); if (insertMode) { // Creazione oggetto identity per nuovo inserimento dataObject.Identity = new ObjectIdentity(DctmConfigurations.GetRepositoryName()); // Modalità di in inserimento, creazione oggetto Identity parent e oggetto relationship ObjectIdentity parentIdentity = DfsHelper.createObjectIdentityByPath(DocsPaAdminCabinet.getRootTitolario(titolario.CodiceAmministrazione)); dataObject.Relationships = new List <Relationship>(); dataObject.Relationships.Add(DfsHelper.createParentFolderRelationship(parentIdentity)); } else { // Reperimento oggetto identity per titolario da modificare dataObject.Identity = titolarioIdentity; } // Impostazione proprietà titolario dataObject.Properties = new PropertySet(); dataObject.Properties.Properties.AddRange(Dfs4DocsPa.getTitolarioProperties(titolario)); DataPackage dataPackage = new DataPackage(dataObject); dataPackage.RepositoryName = DctmConfigurations.GetRepositoryName(); // Save oggetto titolario in documentum if (insertMode) { // Reperimento ACL dell'amministrazione da associare al titolario CustomServices.AclDefinition aclDefinition = Dfs4DocsPa.getAclDefinitionAmministrazione(titolario.CodiceAmministrazione); // Impostazione delle properties relative all'acl per il nodo titolario AclHelper.setAclObjectProperties(dataObject.Properties, aclDefinition); dataPackage = objSrvc.Create(dataPackage, null); } else { dataPackage = objSrvc.Update(dataPackage, null); } retValue = (dataPackage.DataObjects.Count > 0); if (retValue) { logger.Debug(string.Format("Documentum.SaveTitolario: salvato titolario con id {0}", titolario.ID)); } } } catch (Exception ex) { retValue = false; logger.Debug("Errore in Documentum.SaveTitolario: " + ex.ToString()); } return(retValue); }