Пример #1
0
        private List <NetmeraContent> searchFromNetwork()
        {
            RequestItem item = new RequestItem();

            item.path            = NetmeraConstants.Default_ParentPath;
            item.contentType     = NetmeraConstants.Default_ContentType;
            item.max             = max;
            item.page            = page;
            item.sortBy          = sortBy;
            item.sortOrder       = sortOrder.ToString();
            item.customCondition = getCustomCondition();

            if (searchText != null)
            {
                item.searchText = searchText;
            }

            JArray jsonArray = new JArray(NetmeraHttpUtils.search(item));

            return(convertJsonArrayToNetmeraContent(jsonArray));
        }
Пример #2
0
        /// <summary>
        /// Finds the number of <seealso cref="NetmeraContent"/> objects that matches with the query.
        /// </summary>
        /// <returns>Content count</returns>
        public long count()
        {
            RequestItem item = new RequestItem();

            if (searchText != null)
            {
                item.searchText = searchText;
            }

            item.path            = NetmeraConstants.Default_ParentPath;
            item.contentType     = NetmeraConstants.Default_ContentType;
            item.max             = max;
            item.page            = page;
            item.sortBy          = sortBy;
            item.sortOrder       = sortOrder.ToString();
            item.customCondition = getCustomCondition();

            JArray jsonArray = new JArray(NetmeraHttpUtils.search(item));

            return(getNumberOfTotalResults(jsonArray));
        }
Пример #3
0
        private void searchFromNetwork(Action <List <NetmeraContent>, Exception> callback)
        {
            RequestItem item = new RequestItem();

            item.path            = NetmeraConstants.Default_ParentPath;
            item.contentType     = NetmeraConstants.Default_ContentType;
            item.max             = max;
            item.page            = page;
            item.sortBy          = sortBy;
            item.sortOrder       = sortOrder.ToString();
            item.customCondition = getCustomCondition();

            if (searchText != null)
            {
                item.searchText = searchText;
            }

            NetmeraHttpUtils.search(item, (lno, ex) =>
            {
                if (ex != null)
                {
                    if (callback != null)
                    {
                        callback(null, ex);
                    }
                }
                else if (lno != null)
                {
                    try
                    {
                        List <NetmeraContent> contentList = convertJsonArrayToNetmeraContent(new JArray(lno));
                        if (callback != null)
                        {
                            callback(contentList, null);
                        }
                    }
                    catch (JsonException e)
                    {
                        if (callback != null)
                        {
                            callback(null, new NetmeraException(NetmeraException.ErrorCode.EC_INVALID_JSON, "Json in the response of search method is invalid.", e.Message));
                        }
                    }
                    catch (IOException e)
                    {
                        if (callback != null)
                        {
                            callback(null, new NetmeraException(NetmeraException.ErrorCode.EC_IO_EXCEPTION, "IO Exception occurred in search method.", e.Message));
                        }
                    }
                    catch (Exception e)
                    {
                        if (callback != null)
                        {
                            callback(null, new NetmeraException(NetmeraException.ErrorCode.EC_INVALID_REQUEST, "Request exception occurred in search method.", e.Message));
                        }
                    }
                    NetmeraClient.finish();
                }
            });
        }
Пример #4
0
        /// <summary>
        /// Finds the number of <see cref="NetmeraContent"/> objects that matches with the query.
        /// </summary>
        /// <param name="callback">Method called when count operation finishes</param>
        public void count(Action <long, Exception> callback)
        {
            RequestItem item = new RequestItem();

            if (searchText != null)
            {
                item.searchText = searchText;
            }

            item.path            = NetmeraConstants.Default_ParentPath;
            item.contentType     = NetmeraConstants.Default_ContentType;
            item.max             = max;
            item.page            = page;
            item.sortBy          = sortBy;
            item.sortOrder       = sortOrder.ToString();
            item.customCondition = getCustomCondition();

            NetmeraHttpUtils.search(item, (lno, ex) =>
            {
                if (ex != null)
                {
                    if (callback != null)
                    {
                        callback(0, ex);
                    }
                }
                else if (lno != null)
                {
                    try
                    {
                        long count = getNumberOfTotalResults(new JArray(lno));
                        if (callback != null)
                        {
                            callback(count, null);
                        }
                    }
                    catch (JsonException e)
                    {
                        if (callback != null)
                        {
                            callback(0, new NetmeraException(NetmeraException.ErrorCode.EC_INVALID_JSON, "Json in the response of search method is invalid.", e.Message));
                        }
                    }
                    catch (IOException e)
                    {
                        if (callback != null)
                        {
                            callback(0, new NetmeraException(NetmeraException.ErrorCode.EC_IO_EXCEPTION, "IO Exception occurred in search method.", e.Message));
                        }
                    }
                    catch (Exception e)
                    {
                        if (callback != null)
                        {
                            callback(0, new NetmeraException(NetmeraException.ErrorCode.EC_INVALID_REQUEST, "Request exception occurred in search method.", e.Message));
                        }
                    }
                    NetmeraClient.finish();
                }
                NetmeraClient.finish();
            });
        }