Пример #1
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////


        #region Get Methods
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        public IList <Snippet> GetSnippetsForSearch(string searchText, out Dictionary <string, string[]> misSpellings, out int totNum,
                                                    out int totNumWithNonDefOp, out SortedDictionary <string, int> tagsOccurrences, int maxNum = int.MaxValue, int start = 0, bool onlyCreated = false, int onlyOfGroup = 0,
                                                    ItemSortField field = ItemSortField.Relevance, SortDirection direction = SortDirection.Descent)
        {
            //check for erroneous input:
            misSpellings       = null;
            totNum             = 0;
            totNumWithNonDefOp = 0;
            tagsOccurrences    = null;
            if ((maxNum <= 0) || (start < 0))
            {
                SetLastError(log, ErrorCodes.WRONG_INPUT, string.Format("Input error: userID={0}, searchText={1}, maxNum={2}, start={3}",
                                                                        CurrentUserID, searchText.PrintNull(), maxNum, start));
                return(new List <Snippet>());
            }

            //send the request and parse the response:
            string querystring = string.Format("query={0}&maxNum={1}&start={2}&onlyCreated={3}&onlyOfGroup={4}&field={5}&direction={6}",
                                               HttpUtility.UrlEncode(searchText), maxNum, start, onlyCreated, onlyOfGroup, field, direction);
            S2CResListBaseEntity <SnippetComm> resp = SendReqListBaseEntity <SnippetComm>(SEARCH_SNIPPET_URL, querystring, false, false);

            //build the result:
            IList <Snippet> snips = resp.GetListFromResp <SnippetComm, Snippet>(out totNum);

            misSpellings = resp.GetMiscFromResp <SnippetComm>(out totNumWithNonDefOp);
            return(snips);
        }
Пример #2
0
        public IList <Snippet> FindGroupItems(int start, int count, int[] groupIDs, out int totNum,
                                              ItemSortField field = ItemSortField.Relevance, SortDirection direction = SortDirection.Descent)
        {
            //check for erroneous input:
            totNum = 0;
            if ((count <= 0) || (start < 0) || (groupIDs == null) || (groupIDs.Length == 0))
            {
                SetLastError(log, ErrorCodes.WRONG_INPUT, string.Format("Input error: userID={0}, count={1}, start={2}, groupIDs={3}",
                                                                        CurrentUserID, count, start, groupIDs.Print()));
                return(new List <Snippet>());
            }

            //send the request and parse the response:
            string content = Utilities.MergeIntoCommaSeparatedString(groupIDs, true, ' ');

            if (string.IsNullOrEmpty(content))
            {
                return(new List <Snippet>());
            }
            string querystring = string.Format("content={0}&start={1}&count={2}&field={3}&direction={4}",
                                               HttpUtility.UrlEncode(content), start, count, field, direction);
            S2CResListBaseEntity <SnippetComm> resp = SendReqListBaseEntity <SnippetComm>(FINDGROUPS_SNIPPETS_URL, querystring, true, false);

            //build the result:
            IList <Snippet> snips = resp.GetListFromResp <SnippetComm, Snippet>(out totNum);

            return(snips);
        }
Пример #3
0
        public IList <Snippet> FindChannelsItems(int start, int count, ICollection <int> channelsIDs, out int totNum,
                                                 ItemSortField field  = ItemSortField.Relevance, SortDirection direction = SortDirection.Descent,
                                                 bool findAllChannels = false)
        {
            //check for erroneous input:
            totNum = 0;
            if ((count <= 0) || (start < 0) || (channelsIDs.IsNullOrEmpty() && !findAllChannels))
            {
                SetLastError(log, ErrorCodes.WRONG_INPUT, string.Format("Input error: userID={0}, count={1}, start={2}, channelsIDs={3}",
                                                                        CurrentUserID, count, start, channelsIDs.Print()));
                return(new List <Snippet>());
            }

            //exec the SP:
            string search = string.Format("{0}={1}", DefaultProperty.Channel,
                                          (findAllChannels ? "*" : Utilities.MergeIntoCommaSeparatedString(channelsIDs, true)));
            Dictionary <string, string[]> misSpellings = null;
            int totNumWithNonDefOp = 0;
            SortedDictionary <string, int> tagsOccurrences = null;

            return(GetSnippetsForSearch(search, out misSpellings, out totNum, out totNumWithNonDefOp, out tagsOccurrences,
                                        count, start, false, 0, field, direction));
        }
Пример #4
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////


        #region Get Methods
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        public IList<Snippet> GetSnippetsForSearch(string searchText, out Dictionary<string, string[]> misSpellings, out int totNum,
            out int totNumWithNonDefOp, out SortedDictionary<string, int> tagsOccurrences, int maxNum = int.MaxValue, int start = 0, bool onlyCreated = false, int onlyOfGroup = 0,
            ItemSortField field = ItemSortField.Relevance, SortDirection direction = SortDirection.Descent)
        {
            //check for erroneous input:
            misSpellings = null;
            totNum = 0;
            totNumWithNonDefOp = 0;
            tagsOccurrences = null;
            if ((maxNum <= 0) || (start < 0))
            {
                SetLastError(log, ErrorCodes.WRONG_INPUT, string.Format("Input error: userID={0}, searchText={1}, maxNum={2}, start={3}",
                    CurrentUserID, searchText.PrintNull(), maxNum, start));
                return new List<Snippet>();
            }

            //send the request and parse the response:
            string querystring = string.Format("query={0}&maxNum={1}&start={2}&onlyCreated={3}&onlyOfGroup={4}&field={5}&direction={6}",
                                    HttpUtility.UrlEncode(searchText), maxNum, start, onlyCreated, onlyOfGroup, field, direction);
            S2CResListBaseEntity<SnippetComm> resp = SendReqListBaseEntity<SnippetComm>(SEARCH_SNIPPET_URL, querystring, false, false);

            //build the result:
            IList<Snippet> snips = resp.GetListFromResp<SnippetComm, Snippet>(out totNum);
            misSpellings = resp.GetMiscFromResp<SnippetComm>(out totNumWithNonDefOp);
            return snips;
        }
Пример #5
0
        public IList<Snippet> FindChannelsItems(int start, int count, ICollection<int> channelsIDs, out int totNum,
                ItemSortField field = ItemSortField.Relevance, SortDirection direction = SortDirection.Descent,
                bool findAllChannels = false)
        {
            //check for erroneous input:
            totNum = 0;
            if ((count <= 0) || (start < 0) || (channelsIDs.IsNullOrEmpty() && !findAllChannels))
            {
                SetLastError(log, ErrorCodes.WRONG_INPUT, string.Format("Input error: userID={0}, count={1}, start={2}, channelsIDs={3}",
                    CurrentUserID, count, start, channelsIDs.Print()));
                return new List<Snippet>();
            }

            //exec the SP:
            string search = string.Format("{0}={1}", DefaultProperty.Channel,
                (findAllChannels ? "*" : Utilities.MergeIntoCommaSeparatedString(channelsIDs, true)));
            Dictionary<string, string[]> misSpellings = null;
            int totNumWithNonDefOp = 0;
            SortedDictionary<string, int> tagsOccurrences = null; 
            return GetSnippetsForSearch(search, out misSpellings, out totNum, out totNumWithNonDefOp, out tagsOccurrences,
                        count, start, false, 0, field, direction);
        }
Пример #6
0
        public IList<Snippet> FindGroupItems(int start, int count, int[] groupIDs, out int totNum,
            ItemSortField field = ItemSortField.Relevance, SortDirection direction = SortDirection.Descent)
        {
            //check for erroneous input:
            totNum = 0;
            if ((count <= 0) || (start < 0) || (groupIDs == null) || (groupIDs.Length == 0))
            {
                SetLastError(log, ErrorCodes.WRONG_INPUT, string.Format("Input error: userID={0}, count={1}, start={2}, groupIDs={3}",
                    CurrentUserID, count, start, groupIDs.Print()));
                return new List<Snippet>();
            }

            //send the request and parse the response:
            string content = Utilities.MergeIntoCommaSeparatedString(groupIDs, true, ' ');
            if (string.IsNullOrEmpty(content))
                return new List<Snippet>();
            string querystring = string.Format("content={0}&start={1}&count={2}&field={3}&direction={4}",
                HttpUtility.UrlEncode(content), start, count, field, direction);
            S2CResListBaseEntity<SnippetComm> resp = SendReqListBaseEntity<SnippetComm>(FINDGROUPS_SNIPPETS_URL, querystring, true, false);

            //build the result:
            IList<Snippet> snips = resp.GetListFromResp<SnippetComm, Snippet>(out totNum);
            return snips;
        }