예제 #1
0
 /// <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))));
 }
예제 #2
0
        /// <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);
        }