コード例 #1
0
        /// <summary>
        /// Prepares and returns the keyword query to get data from SharePoint Search based on filtering condition.
        /// </summary>
        /// <param name="client">The client object</param>
        /// <param name="searchObject">The search object.</param>
        /// <param name="keywordQuery">The keyword query.</param>
        /// <param name="filterCondition">The filter condition.</param>
        /// <param name="managedProperty">The managed property.</param>
        /// <param name="isMatterView">If the user is pinning a matter, this will be true, else will be false.</param>
        /// <returns>It returns a Keyword Query object.</returns>
        internal static KeywordQuery KeywordQueryMetrics(Client client, SearchObject searchObject, KeywordQuery keywordQuery, string filterCondition, string managedProperty, bool isMatterView)
        {
            KeywordQuery result = null;
            try
            {
                if (ServiceConstantStrings.IsTenantDeployment)
                {
                    keywordQuery.QueryText = searchObject.SearchTerm;
                }
                else
                {
                    keywordQuery.QueryText = "(" + searchObject.SearchTerm + " AND site:" + client.Url + ")";
                }

                keywordQuery.RefinementFilters.Add(filterCondition);
                if (isMatterView)
                {
                    keywordQuery.RefinementFilters.Add(string.Concat(managedProperty, ConstantStrings.COLON, ConstantStrings.DoubleQuote, true, ConstantStrings.DoubleQuote));
                }
                else
                {

                    string[] invalidExtensions = ServiceConstantStrings.FindDocumentInvalidExtensions.Split(',');
                    string chunk = string.Empty;

                    foreach (string extension in invalidExtensions)
                    {
                        chunk = chunk + "equals" + ConstantStrings.OpeningBracket + ConstantStrings.DoubleQuote + extension + ConstantStrings.DoubleQuote + ConstantStrings.ClosingBracket + ConstantStrings.Comma;
                    }
                    chunk = chunk.Remove(chunk.Length - 1);

                    keywordQuery.RefinementFilters.Add(string.Concat("not" + ConstantStrings.OpeningBracket + "FileType", ConstantStrings.COLON, ConstantStrings.OperatorOR + ConstantStrings.OpeningBracket +
                                                                                                            chunk + ConstantStrings.ClosingBracket + ConstantStrings.ClosingBracket
                                                                                                            ));
                    keywordQuery.RefinementFilters.Add(string.Concat(managedProperty, ConstantStrings.COLON, "equals", ConstantStrings.OpeningBracket + ConstantStrings.DoubleQuote +
                                                                                                            "1" + ConstantStrings.DoubleQuote + ConstantStrings.ClosingBracket
                                                                                                            ));
                }

                keywordQuery.TrimDuplicates = false;
                if (0 < searchObject.PageNumber && 0 < searchObject.ItemsPerPage)
                {
                    keywordQuery.StartRow = (searchObject.PageNumber - 1) * searchObject.ItemsPerPage;
                    keywordQuery.RowLimit = searchObject.ItemsPerPage;
                }

                result = keywordQuery;
            }
            catch (Exception exception)
            {
                Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ServiceConstantStrings.LogTableName);
                result = null;
            }
            return result;
        }
コード例 #2
0
        /// <summary>
        /// Returns the query to filter the matters.
        /// </summary>
        /// <param name="searchObject">The search object.</param>
        /// <param name="keywordQuery">The keyword query.</param>
        /// <returns>It returns a keyword query object.</returns>
        internal static KeywordQuery FilterMattersUtility(SearchObject searchObject, KeywordQuery keywordQuery)
        {
            if (null != searchObject && null != keywordQuery && null != searchObject.Filters)
            {
                /* New refinement filters for list view control */
                if (!string.IsNullOrWhiteSpace(searchObject.Filters.Name))
                {
                    keywordQuery.RefinementFilters.Add(string.Concat(SearchConstants.ManagedPropertyMatterName, ConstantStrings.COLON, ConstantStrings.DoubleQuote, searchObject.Filters.Name, ConstantStrings.DoubleQuote));
                }

                if (!string.IsNullOrWhiteSpace(searchObject.Filters.ClientName))
                {
                    keywordQuery.RefinementFilters.Add(string.Concat(SearchConstants.ManagedPropertyClientName, ConstantStrings.COLON, ConstantStrings.DoubleQuote, searchObject.Filters.ClientName, ConstantStrings.DoubleQuote));
                }

                if (null != searchObject.Filters.ResponsibleAttorneys && !string.IsNullOrWhiteSpace(searchObject.Filters.ResponsibleAttorneys))
                {
                    keywordQuery.RefinementFilters.Add(string.Concat(SearchConstants.ManagedPropertyResponsibleAttorney, ConstantStrings.COLON, ConstantStrings.DoubleQuote, searchObject.Filters.ResponsibleAttorneys, ConstantStrings.DoubleQuote));
                }

                if (!string.IsNullOrWhiteSpace(searchObject.Filters.SubareaOfLaw))
                {
                    keywordQuery.RefinementFilters.Add(string.Concat(SearchConstants.ManagedPropertySubAreaOfLaw, ConstantStrings.COLON, ConstantStrings.DoubleQuote, searchObject.Filters.SubareaOfLaw, ConstantStrings.DoubleQuote));
                }
                if (null != searchObject.Filters.DateFilters)
                {
                    ////// Add refiner for Open date value
                    keywordQuery = AddDateRefinementFilter(keywordQuery, searchObject.Filters.DateFilters.OpenDateFrom, searchObject.Filters.DateFilters.OpenDateTo, SearchConstants.ManagedPropertyOpenDate);
                }
            }

            return keywordQuery;
        }
コード例 #3
0
 /// <summary>
 /// Defines the sorting property and direction for querying SharePoint Search.
 /// </summary>
 /// <param name="keywordQuery">Keyword object</param>
 /// <param name="searchObject">Search object</param>
 /// <param name="isMatterSearch">Boolean flag which determines current search is for matters or documents</param>
 /// <returns></returns>
 internal static KeywordQuery GetSortByProperty(KeywordQuery keywordQuery, SearchObject searchObject, Boolean isMatterSearch)
 {
     string matterIDRefiner = string.Empty;
     ////Sorting by specified property  0 --> Ascending order and 1 --> Descending order
     if (!string.IsNullOrWhiteSpace(searchObject.Sort.ByProperty))
     {
         keywordQuery = AddSortingRefiner(keywordQuery, searchObject.Sort.ByProperty, searchObject.Sort.Direction);
         //// Add Matter ID property as second level sort for Client.MatterID column based on Search Matter or Search Document
         if (SearchConstants.ManagedPropertyClientID == searchObject.Sort.ByProperty || SearchConstants.ManagedPropertyDocumentClientId == searchObject.Sort.ByProperty)
         {
             if (isMatterSearch)
             {
                 matterIDRefiner = SearchConstants.ManagedPropertyMatterId;
             }
             else
             {
                 matterIDRefiner = SearchConstants.ManagedPropertyDocumentMatterId;
             }
             keywordQuery = AddSortingRefiner(keywordQuery, matterIDRefiner, searchObject.Sort.Direction);
         }
     }
     return keywordQuery;
 }
コード例 #4
0
        /// <summary>
        /// Prepares and returns the query to filter the documents.
        /// </summary>
        /// <param name="searchObject">The search object.</param>
        /// <param name="keywordQuery">The keyword query.</param>
        /// <returns>It returns a Keyword Query object.</returns>
        internal static KeywordQuery FilterDocuments(SearchObject searchObject, KeywordQuery keywordQuery)
        {
            string filterValues = string.Empty;
            if (null != searchObject && null != keywordQuery)
            {
                if (null != searchObject.Filters)
                {
                    keywordQuery = AddDateRefinementFilter(keywordQuery, searchObject.Filters.FromDate, searchObject.Filters.ToDate, SearchConstants.ManagedPropertyCreated);
                    if (null != searchObject.Filters.DocumentAuthor && !string.IsNullOrWhiteSpace(searchObject.Filters.DocumentAuthor))
                    {
                        keywordQuery.RefinementFilters.Add(string.Concat(SearchConstants.ManagedPropertyAuthor, ConstantStrings.COLON, ConstantStrings.DoubleQuote, searchObject.Filters.DocumentAuthor, ConstantStrings.DoubleQuote));
                    }

                    if (0 < searchObject.Filters.ClientsList.Count && !string.IsNullOrWhiteSpace(searchObject.Filters.ClientsList[0]))
                    {
                        filterValues = SearchHelperFunctions.FormFilterQuery(SearchConstants.ManagedPropertyDocumentClientName, searchObject.Filters.ClientsList);
                        keywordQuery.RefinementFilters.Add(filterValues);
                    }

                    /* New refinement filters for list view control */

                    if (!string.IsNullOrWhiteSpace(searchObject.Filters.Name))
                    {
                        keywordQuery.RefinementFilters.Add(string.Concat(SearchConstants.ManagedPropertyFileName, ConstantStrings.COLON, ConstantStrings.DoubleQuote, searchObject.Filters.Name, ConstantStrings.DoubleQuote));
                    }

                    if (!string.IsNullOrWhiteSpace(searchObject.Filters.ClientName))
                    {
                        keywordQuery.RefinementFilters.Add(string.Concat(SearchConstants.ManagedPropertyDocumentClientName, ConstantStrings.COLON, ConstantStrings.DoubleQuote, searchObject.Filters.ClientName, ConstantStrings.DoubleQuote));
                    }

                    if (null != searchObject.Filters.DocumentCheckoutUsers && !string.IsNullOrWhiteSpace(searchObject.Filters.DocumentCheckoutUsers))
                    {
                        keywordQuery.RefinementFilters.Add(string.Concat(SearchConstants.ManagedPropertyDocumentCheckOutUser, ConstantStrings.COLON, ConstantStrings.DoubleQuote, searchObject.Filters.DocumentCheckoutUsers, ConstantStrings.DoubleQuote));
                    }
                }
                keywordQuery = FilterCommonDetails(searchObject, keywordQuery, false);
            }
            return keywordQuery;
        }
コード例 #5
0
        /// <summary>
        /// Returns the query to filter the matters.
        /// </summary>
        /// <param name="searchObject">The search object.</param>
        /// <param name="keywordQuery">The keyword query.</param>
        /// <returns>It returns a keyword query object.</returns>
        internal static KeywordQuery FilterMatters(SearchObject searchObject, KeywordQuery keywordQuery)
        {
            string filterValues = string.Empty;
            if (null != searchObject && null != keywordQuery)
            {
                if (null != searchObject.Filters)
                {
                    if (null != searchObject.Filters.AOLList && 0 < searchObject.Filters.AOLList.Count && !string.IsNullOrWhiteSpace(searchObject.Filters.AOLList[0]))
                    {
                        filterValues = SearchHelperFunctions.FormFilterQuery(SearchConstants.ManagedPropertyAreaOfLaw, searchObject.Filters.AOLList);
                        keywordQuery.RefinementFilters.Add(filterValues);
                    }

                    if (null != searchObject.Filters.PGList && 0 < searchObject.Filters.PGList.Count && !string.IsNullOrWhiteSpace(searchObject.Filters.PGList[0]))
                    {
                        filterValues = SearchHelperFunctions.FormFilterQuery(SearchConstants.ManagedPropertyPracticeGroup, searchObject.Filters.PGList);
                        keywordQuery.RefinementFilters.Add(filterValues);
                    }
                    keywordQuery = AddDateRefinementFilter(keywordQuery, searchObject.Filters.FromDate, searchObject.Filters.ToDate, SearchConstants.ManagedPropertyOpenDate);
                    if (null != searchObject.Filters.ClientsList && 0 < searchObject.Filters.ClientsList.Count && !string.IsNullOrWhiteSpace(searchObject.Filters.ClientsList[0]))
                    {
                        filterValues = SearchHelperFunctions.FormFilterQuery(SearchConstants.ManagedPropertyClientName, searchObject.Filters.ClientsList);
                        keywordQuery.RefinementFilters.Add(filterValues);
                    }
                }

                keywordQuery = FilterMattersUtility(searchObject, keywordQuery);

                keywordQuery = SearchHelperFunctions.FilterCommonDetails(searchObject, keywordQuery, true);
            }
            return keywordQuery;
        }
コード例 #6
0
        /// <summary>
        /// Returns the query to filter the matters/ documents for common filters.
        /// </summary>
        /// <param name="searchObject">The search object.</param>
        /// <param name="keywordQuery">The keyword query.</param>
        /// <param name="isMatterView">Flag to identify matters/documents view.</param>
        /// <returns>It returns a keyword query object.</returns>
        internal static KeywordQuery FilterCommonDetails(SearchObject searchObject, KeywordQuery keywordQuery, bool isMatterView)
        {
            if (null != searchObject && null != keywordQuery)
            {

                if (null != searchObject.Filters.DateFilters)
                {
                    string lastModifiedTime = SearchConstants.ManagedPropertyLastModifiedTime;
                    //// Add refiner for Modified date value
                    if (!isMatterView)
                    {
                        lastModifiedTime = SearchConstants.ManagedPropertyDocumentLastModifiedTime;
                    }
                    keywordQuery = AddDateRefinementFilter(keywordQuery, searchObject.Filters.DateFilters.ModifiedFromDate, searchObject.Filters.DateFilters.ModifiedToDate, lastModifiedTime);

                    ////// Add refiner for Created date value
                    keywordQuery = AddDateRefinementFilter(keywordQuery, searchObject.Filters.DateFilters.CreatedFromDate, searchObject.Filters.DateFilters.CreatedToDate, SearchConstants.ManagedPropertyCreated);
                }
            }
            return keywordQuery;
        }
コード例 #7
0
        /// <summary>
        /// Fires query on SharePoint Search and fills the result data.
        /// </summary>
        /// <param name="clientContext">The client context.</param>
        /// <param name="keywordQuery">The keyword query.</param>
        /// <param name="searchObject">The search object.</param>
        /// <param name="isMatterSearch">The flag to determine weather call is from Search Matter or Search Document.</param>
        /// <param name="managedProperties">List of managed properties</param>
        /// <returns>It returns a string object, that contains all the results combined with dollar pipe dollar separator.</returns>
        internal static string FillResultData(ClientContext clientContext, KeywordQuery keywordQuery, SearchObject searchObject, Boolean isMatterSearch, List<string> managedProperties)
        {
            string result = string.Empty;
            Boolean isReadOnly;
            try
            {
                if (null != searchObject.Sort)
                {
                    keywordQuery.EnableSorting = true;
                    keywordQuery = SearchHelperFunctions.GetSortByProperty(keywordQuery, searchObject, isMatterSearch);
                }
                SearchExecutor searchExecutor = new SearchExecutor(clientContext);
                ClientResult<ResultTableCollection> resultsTableCollection = searchExecutor.ExecuteQuery(keywordQuery);
                Users currentLoggedInUser = UIUtility.GetLoggedInUserDetails(clientContext);

                if (null != resultsTableCollection && null != resultsTableCollection.Value && 0 < resultsTableCollection.Value.Count && null != resultsTableCollection.Value[0].ResultRows)
                {
                    if (isMatterSearch && 0 < resultsTableCollection.Value.Count && null != resultsTableCollection.Value[0].ResultRows && (!string.IsNullOrWhiteSpace(currentLoggedInUser.Name) || !string.IsNullOrWhiteSpace(currentLoggedInUser.Email)))
                    {
                        foreach (IDictionary<string, object> matterMetadata in resultsTableCollection.Value[0].ResultRows)
                        {
                            isReadOnly = false;
                            if (null != matterMetadata)
                            {
                                // Decode matter properties
                                DecodeMatterProperties(matterMetadata);
                                string readOnlyUsers = Convert.ToString(matterMetadata[SearchConstants.ManagedPropertyBlockedUploadUsers], CultureInfo.InvariantCulture);
                                if (!string.IsNullOrWhiteSpace(readOnlyUsers))
                                {
                                    isReadOnly = IsUserReadOnlyForMatter(isReadOnly, currentLoggedInUser.Name, currentLoggedInUser.Email, readOnlyUsers);
                                }
                                matterMetadata.Add(TextConstants.IsReadOnlyUser, isReadOnly);
                            }
                        }
                    }
                    else
                    {
                        /*Keeping the code to clean the author values*/
                        foreach (IDictionary<string, object> documentMetadata in resultsTableCollection.Value[0].ResultRows)
                        {
                            if (null != documentMetadata)
                            {
                                string authorData = Convert.ToString(documentMetadata[SearchConstants.ManagedPropertyAuthor], CultureInfo.InvariantCulture);
                                int ltIndex = authorData.IndexOf(ConstantStrings.OpeningAngularBracket, StringComparison.Ordinal);
                                int gtIndex = authorData.IndexOf(ConstantStrings.ClosingAngularBracket, StringComparison.Ordinal);
                                authorData = (0 <= ltIndex && ltIndex < gtIndex) ? authorData.Remove(ltIndex, (gtIndex - ltIndex) + 1) : authorData;
                                authorData = authorData.Replace(ServiceConstantStrings.DoubleQuotes, string.Empty);
                                documentMetadata[SearchConstants.ManagedPropertyAuthor] = authorData.Trim();
                            }
                        }
                    }
                    if (1 < resultsTableCollection.Value.Count)
                    {
                        result = string.Concat(JsonConvert.SerializeObject(resultsTableCollection.Value[0].ResultRows), ConstantStrings.DOLLAR, ConstantStrings.Pipe, ConstantStrings.DOLLAR, resultsTableCollection.Value[0].TotalRows, ConstantStrings.DOLLAR, ConstantStrings.Pipe, ConstantStrings.DOLLAR, JsonConvert.SerializeObject(resultsTableCollection.Value[1].ResultRows));
                    }
                    else
                    {
                        if (0 == resultsTableCollection.Value[0].TotalRows)
                        {
                            result = SearchHelperFunctions.NoDataRow(managedProperties);
                        }
                        else
                        {
                            result = string.Concat(JsonConvert.SerializeObject(resultsTableCollection.Value[0].ResultRows), ConstantStrings.DOLLAR, ConstantStrings.Pipe, ConstantStrings.DOLLAR, resultsTableCollection.Value[0].TotalRows);
                        }
                    }
                }
                else
                {
                    result = SearchHelperFunctions.NoDataRow(managedProperties);
                }
            }
            catch (Exception exception)
            {
                result = Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ServiceConstantStrings.LogTableName);
            }
            return result;
        }
コード例 #8
0
 public string GetUsers(RequestObject requestObject, Client client, SearchObject searchObject)
 {
     string returnValue = ConstantStrings.FALSE;
     if (null != requestObject && null != client && null != searchObject && ValidationHelperFunctions.CheckRequestValidatorToken())
     {
         string ProvisionMatterValidation = ValidationHelperFunctions.ProvisionMatterValidation(requestObject, client, null, null, null, int.Parse(ConstantStrings.ProvisionMatterCommonValidation, CultureInfo.InvariantCulture), null);
         if (string.IsNullOrWhiteSpace(ProvisionMatterValidation))
         {
             try
             {
                 searchObject.SearchTerm = (!string.IsNullOrWhiteSpace(searchObject.SearchTerm)) ? searchObject.SearchTerm : string.Empty;
                 using (ClientContext clientContext = ServiceUtility.GetClientContext(requestObject.SPAppToken, new Uri(client.Url), requestObject.RefreshToken))
                 {
                     IList<PeoplePickerUser> foundUsers = SharePointHelper.SearchUsers(clientContext, searchObject.SearchTerm);
                     IList<Users> users = new List<Users>();
                     if (null != foundUsers && 0 != foundUsers.Count)
                     {
                         users = ProvisionHelperFunctions.FilterUsers(users, foundUsers);
                     }
                     else
                     {
                         Users noResult = new Users()
                         {
                             Name = TextConstants.PeoplePickerNoResults,
                             LogOnName = string.Empty,
                             Email = string.Empty,
                             EntityType = string.Empty,
                             ProviderName = string.Empty,
                             EntityData = new EntityData()
                             {
                                 Department = string.Empty,
                                 Email = string.Empty,
                                 Title = string.Empty
                             }
                         };
                         users.Add(noResult);
                     }
                     returnValue = JsonConvert.SerializeObject(users);
                 }
             }
             catch (Exception exception)
             {
                 ///// SharePoint Specific Exception
                 returnValue = Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ServiceConstantStrings.LogTableName);
             }
         }
         else
         {
             returnValue = ProvisionMatterValidation;
         }
     }
     else
     {
         returnValue = string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, string.Empty, TextConstants.MessageNoInputs);
     }
     return returnValue;
 }
コード例 #9
0
        public string FindMatter(RequestObject requestObject, Client client, SearchObject searchObject)
        {
            string result = string.Empty;
            if (null != requestObject && null != client & null != searchObject && ValidationHelperFunctions.CheckRequestValidatorToken())
            {
                try
                {
                    // Encode all fields which are coming from js
                    SearchHelperFunctions.EncodeSearchDetails(searchObject.Filters, true);
                    // Encode Search Term
                    searchObject.SearchTerm = (null != searchObject.SearchTerm) ? Encoder.HtmlEncode(searchObject.SearchTerm).Replace(ConstantStrings.ENCODEDDOUBLEQUOTES, ConstantStrings.DoubleQuote) : string.Empty;

                    using (ClientContext clientContext = ServiceUtility.GetClientContext(requestObject.SPAppToken, new Uri(client.Url), requestObject.RefreshToken))
                    {
                        KeywordQuery keywordQuery = new KeywordQuery(clientContext);
                        if (string.IsNullOrWhiteSpace(searchObject.SearchTerm))
                        {
                            searchObject.SearchTerm = ConstantStrings.Asterisk;
                        }

                        if (null != searchObject.Filters)
                        {
                            if (1 == searchObject.Filters.FilterByMe)
                            {
                                ////Get logged in user alias
                                Users currentUserDetail = UIUtility.GetLoggedInUserDetails(clientContext);
                                string userTitle = currentUserDetail.Name;
                                searchObject.SearchTerm = string.Concat(searchObject.SearchTerm, ConstantStrings.Space, ConstantStrings.OperatorAnd, ConstantStrings.Space, ConstantStrings.OpeningBracket, SearchConstants.ManagedPropertyResponsibleAttorney, ConstantStrings.COLON, ConstantStrings.Space, ConstantStrings.DoubleQuote, userTitle, ConstantStrings.DoubleQuote, ConstantStrings.Space, ConstantStrings.OperatorOR, ConstantStrings.Space, SearchConstants.ManagedPropertyTeamMembers, ConstantStrings.COLON, ConstantStrings.Space, ConstantStrings.DoubleQuote, userTitle, ConstantStrings.DoubleQuote, ConstantStrings.Space, ConstantStrings.ClosingBracket);
                            }

                            keywordQuery = SearchHelperFunctions.FilterMatters(searchObject, keywordQuery);
                        }

                        keywordQuery = SearchHelperFunctions.KeywordQueryMetrics(client, searchObject, keywordQuery, ConstantStrings.DocumentLibraryFilterCondition, SearchConstants.ManagedPropertyIsMatter, true);

                        // Create a list of managed properties which are required to be present in search results
                        List<string> managedProperties = new List<string>();
                        managedProperties.Add(SearchConstants.ManagedPropertyTitle);
                        managedProperties.Add(SearchConstants.ManagedPropertyName);
                        managedProperties.Add(SearchConstants.ManagedPropertyDescription);
                        managedProperties.Add(SearchConstants.ManagedPropertySiteName);
                        managedProperties.Add(SearchConstants.ManagedPropertyLastModifiedTime);
                        managedProperties.Add(SearchConstants.ManagedPropertyPracticeGroup);
                        managedProperties.Add(SearchConstants.ManagedPropertyAreaOfLaw);
                        managedProperties.Add(SearchConstants.ManagedPropertySubAreaOfLaw);
                        managedProperties.Add(SearchConstants.ManagedPropertyMatterId);
                        managedProperties.Add(SearchConstants.ManagedPropertyCustomTitle);
                        managedProperties.Add(SearchConstants.ManagedPropertyPath);
                        managedProperties.Add(SearchConstants.ManagedPropertyMatterName);
                        managedProperties.Add(SearchConstants.ManagedPropertyOpenDate);
                        managedProperties.Add(SearchConstants.ManagedPropertyClientName);
                        managedProperties.Add(SearchConstants.ManagedPropertyBlockedUploadUsers);
                        managedProperties.Add(SearchConstants.ManagedPropertyResponsibleAttorney);
                        managedProperties.Add(SearchConstants.ManagedPropertyClientID);
                        managedProperties.Add(SearchConstants.ManagedPropertyMatterGuid);

                        //Filter on Result source to fetch only Matter Center specific results
                        keywordQuery.SourceId = new Guid(SearchConstants.SearchResultSourceID);

                        keywordQuery = SearchHelperFunctions.AssignKeywordQueryValues(keywordQuery, managedProperties);

                        keywordQuery.BypassResultTypes = true;

                        result = SearchHelperFunctions.FillResultData(clientContext, keywordQuery, searchObject, true, managedProperties);
                    }
                }
                catch (Exception exception)
                {
                    result = Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ServiceConstantStrings.LogTableName);
                }
            }
            else
            {
                result = string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, string.Empty, TextConstants.MessageNoInputs);
            }
            return result;
        }
コード例 #10
0
        public string FindDocument(RequestObject requestObject, Client client, SearchObject searchObject)
        {
            string result = string.Empty;
            if (null != requestObject && null != client & null != searchObject && ValidationHelperFunctions.CheckRequestValidatorToken())
            {
                try
                {
                    // Encode all fields which are coming from js
                    SearchHelperFunctions.EncodeSearchDetails(searchObject.Filters, false);
                    // Encode Search Term
                    searchObject.SearchTerm = (null != searchObject.SearchTerm) ? Encoder.HtmlEncode(searchObject.SearchTerm).Replace(ConstantStrings.ENCODEDDOUBLEQUOTES, ConstantStrings.DoubleQuote) : string.Empty;

                    using (ClientContext clientContext = ServiceUtility.GetClientContext(requestObject.SPAppToken, new Uri(client.Url), requestObject.RefreshToken))
                    {
                        KeywordQuery keywordQuery = new KeywordQuery(clientContext);
                        if (string.IsNullOrWhiteSpace(searchObject.SearchTerm))
                        {
                            searchObject.SearchTerm = ConstantStrings.Asterisk;
                        }

                        if (null != searchObject.Filters)
                        {
                            if (1 == searchObject.Filters.FilterByMe)
                            {
                                // Get the current logged in User
                                clientContext.Load(clientContext.Web.CurrentUser);
                                clientContext.ExecuteQuery();
                                string currentLoggedInUser = clientContext.Web.CurrentUser.Title;
                                searchObject.SearchTerm = String.Concat(searchObject.SearchTerm, ConstantStrings.Space, ConstantStrings.OperatorAnd, ConstantStrings.Space, SearchConstants.ManagedPropertyAuthor, ConstantStrings.COLON, currentLoggedInUser);
                            }
                            keywordQuery = SearchHelperFunctions.FilterDocuments(searchObject, keywordQuery);
                        }

                        keywordQuery = SearchHelperFunctions.KeywordQueryMetrics(client, searchObject, keywordQuery, ConstantStrings.DocumentItemFilterCondition, SearchConstants.ManagedPropertyIsDocument, false);

                        //// Create a list of managed properties which are required to be present in search results
                        List<string> managedProperties = new List<string>();
                        managedProperties.Add(SearchConstants.ManagedPropertyFileName);
                        managedProperties.Add(SearchConstants.ManagedPropertyTitle);
                        managedProperties.Add(SearchConstants.ManagedPropertyCreated);
                        managedProperties.Add(SearchConstants.ManagedPropertyUIVersionStringOWSTEXT);
                        managedProperties.Add(SearchConstants.ManagedPropertyServerRelativeUrl);
                        managedProperties.Add(SearchConstants.ManagedPropertyFileExtension);
                        managedProperties.Add(SearchConstants.ManagedPropertyDocumentMatterId);
                        managedProperties.Add(SearchConstants.ManagedPropertyDocumentLastModifiedTime);
                        managedProperties.Add(SearchConstants.ManagedPropertySiteTitle);
                        managedProperties.Add(SearchConstants.ManagedPropertyDocumentClientId);
                        managedProperties.Add(SearchConstants.ManagedPropertyDocumentClientName);
                        managedProperties.Add(SearchConstants.ManagedPropertyDocumentMatterName);
                        managedProperties.Add(SearchConstants.ManagedPropertyDocumentId);
                        managedProperties.Add(SearchConstants.ManagedPropertyCheckOutByUser);
                        managedProperties.Add(SearchConstants.ManagedPropertySiteName);
                        managedProperties.Add(SearchConstants.ManagedPropertySPWebUrl);
                        managedProperties.Add(SearchConstants.ManagedPropertyDocumentVersion);
                        managedProperties.Add(SearchConstants.ManagedPropertyDocumentCheckOutUser);
                        managedProperties.Add(SearchConstants.ManagedPropertySPWebUrl);
                        managedProperties.Add(SearchConstants.ManagedPropertyAuthor);

                        //Filter on Result source to fetch only Matter Center specific results
                        keywordQuery.SourceId = new Guid(SearchConstants.SearchResultSourceID);

                        keywordQuery = SearchHelperFunctions.AssignKeywordQueryValues(keywordQuery, managedProperties);

                        result = SearchHelperFunctions.FillResultData(clientContext, keywordQuery, searchObject, false, managedProperties);
                    }
                }
                catch (Exception exception)
                {
                    result = Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ServiceConstantStrings.LogTableName);
                }
            }
            else
            {
                result = TextConstants.MessageNoInputs;
            }
            return result;
        }