Exemple #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);
        }
Exemple #2
0
        public IList <int> GetChannelIDsOfUser(int userID)
        {
            if (userID <= 0)
            {
                SetLastError(log, ErrorCodes.WRONG_INPUT, string.Format("Input error: userID={0}", userID));
                return(new List <int>());
            }

            //send the request and parse the response:
            string querystring = string.Format("ID={0}", userID);
            S2CResListBaseEntity <GroupComm> resp = SendReqListBaseEntity <GroupComm>(GET_CHANNELIDS_URL, querystring, false);

            //build the result:
            int          totNum = 0;
            List <Group> g      = resp.GetListFromResp <GroupComm, Group>(out totNum);

            if (g != null)
            {
                return(g.Select((group) => group.ID) as IList <int>);
            }
            else
            {
                return(new List <int>());
            }
        }
Exemple #3
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);
        }
Exemple #4
0
        public List <Badge> GetBadges(int userID)
        {
            if (userID <= 0)
            {
                SetLastError(log, ErrorCodes.WRONG_INPUT, string.Format("Input error: userID={0}", userID));
                return(new List <Badge>());
            }

            //send the request and parse the response:
            string querystring = string.Format("ID={0}", userID);
            S2CResListBaseEntity <Badge> resp = SendReqListBaseEntity <Badge>(GET_BADGES_URL, querystring, false);

            //build the result:
            int totNum = 0;

            return(resp.GetListFromResp <Badge, Badge>(out totNum));
        }
Exemple #5
0
        public IList <Group> GetAdministeredChannelsOfUser(int userID)
        {
            if (userID <= 0)
            {
                SetLastError(log, ErrorCodes.WRONG_INPUT, string.Format("Input error: userID={0}", userID));
                return(new List <Group>());
            }

            //send the request and parse the response:
            string querystring = string.Format("ID={0}", userID);
            S2CResListBaseEntity <GroupComm> resp = SendReqListBaseEntity <GroupComm>(GET_ADMINISTEREDCHANNELS_URL, querystring, false);

            //build the result:
            int totNum = 0;

            return(resp.GetListFromResp <GroupComm, Group>(out totNum));
        }
Exemple #6
0
        public ICollection <Snippet> GetMostCorrelatedSnippets(long snippetID)
        {
            //check for erroneous input:
            if (snippetID <= 0)
            {
                SetLastError(log, ErrorCodes.WRONG_INPUT, string.Format("Input error: snippetID={0}", snippetID));
                return(new List <Snippet>());
            }

            //send the request and parse the response:
            S2CResListBaseEntity <SnippetComm> resp = SendReqListBaseEntity <SnippetComm>(GET_MOSTCORRELATED_URL, "id=" + snippetID, false, false);

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

            return(snips);
        }
Exemple #7
0
        public List <Badge> GetBadges(long snippetID)
        {
            //check for erroneous input:
            if (snippetID <= 0)
            {
                SetLastError(log, ErrorCodes.WRONG_INPUT, string.Format("Input error: snippetID={0}", snippetID));
                return(new List <Badge>());
            }

            //send the request and parse the response:
            S2CResListBaseEntity <Badge> resp = SendReqListBaseEntity <Badge>(GET_BADGES_URL, "id=" + snippetID, false, false);

            //build the result:
            int          totNum = 0;
            List <Badge> badges = resp.GetListFromResp <Badge, Badge>(out totNum);

            return(badges);
        }
Exemple #8
0
        public ICollection <Group> GetGroupsOfUser(int userID)
        {
            if (userID <= 0)
            {
                SetLastError(log, ErrorCodes.WRONG_INPUT, string.Format("Input error: userID={0}", userID));
                return(new List <Group>());
            }

            //send the request and parse the response:
            string querystring = string.Format("ID={0}", userID);
            S2CResListBaseEntity <GroupComm> resp = SendReqListBaseEntity <GroupComm>(GET_GROUPS_URL, querystring, false);

            //build the result:
            int          totNum = 0;
            List <Group> g      = resp.GetListFromResp <GroupComm, Group>(out totNum);

            return(g);
        }
Exemple #9
0
        public IList <Snippet> FindGroupItems(int start, int count, int groupID, out int totNum)
        {
            //check for erroneous input:
            totNum = 0;
            if ((count <= 0) || (start < 0))
            {
                SetLastError(log, ErrorCodes.WRONG_INPUT,
                             string.Format("Input error: userID={0}, count={1}, start={2}", CurrentUserID, count, start));
                return(new List <Snippet>());
            }

            //send the request and parse the response:
            string querystring = string.Format("groupID={0}&start={1}&count={2}", groupID, start, count);
            S2CResListBaseEntity <SnippetComm> resp = SendReqListBaseEntity <SnippetComm>(FINDGROUP_SNIPPETS_URL, querystring, false, false);

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

            return(snips);
        }
Exemple #10
0
        public IList <Snippet> FindItems(long[] snippetIDs, bool keepOrdering = false)
        {
            //check for erroneous input:
            if ((snippetIDs == null) || (snippetIDs.Length == 0))
            {
                return(new List <Snippet>());
            }

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

            if (string.IsNullOrEmpty(content))
            {
                return(new List <Snippet>());
            }
            string querystring = string.Format("content={0}", HttpUtility.UrlEncode(content));
            S2CResListBaseEntity <SnippetComm> resp = SendReqListBaseEntity <SnippetComm>(FIND_SNIPPETS_URL, querystring, true, false);

            //build the result:
            int totNum = 0;

            return(resp.GetListFromResp <SnippetComm, Snippet>(out totNum));
        }