Ejemplo n.º 1
0
        private DataSet QueryResultsParseDataSet(string fields, NamedList namedList, string highlightFields, out long recordCount)
        {
            ObjectDeserializeTable <T> objectDeserializeTable = new ObjectDeserializeTable <T>(this._TableName, fields);
            ISolrResponseParser <NamedList, QueryResults <DataRow> > solrResponseParser = new BinaryQueryResultsParser <DataRow>(objectDeserializeTable);

            if (!string.IsNullOrWhiteSpace(highlightFields))
            {
                BinaryHighlightingParser binaryHighlightingParser = new BinaryHighlightingParser();
                IDictionary <string, IDictionary <string, IList <string> > > highlight = binaryHighlightingParser.Parse(namedList);
                objectDeserializeTable.Highlight = highlight;
            }
            QueryResults <DataRow> queryResults = solrResponseParser.Parse(namedList);

            recordCount = queryResults.NumFound;
            DataSet   dataSet   = new DataSet();
            DataTable dataTable = objectDeserializeTable.CreateDataTable();

            foreach (DataRow current in queryResults)
            {
                dataTable.Rows.Add(current.ItemArray);
            }
            dataSet.Tables.Add(dataTable);
            DataTable dataTable2 = new DataTable();

            dataTable2.TableName = "RecordCount";
            dataTable2.Columns.Add("RecordCount", typeof(long));
            DataRow dataRow = dataTable2.NewRow();

            dataRow["RecordCount"] = recordCount;
            dataTable2.Rows.Add(dataRow);
            dataSet.Tables.Add(dataTable2);
            return(dataSet);
        }
Ejemplo n.º 2
0
        public static DataSet ParserResultsDataSet <T>(this NamedList namedList, string fields, out long recordCount, string tableName = "") where T : class, new()
        {
            ObjectDeserializeTable <T> objectDeserializeTable = new ObjectDeserializeTable <T>(tableName, fields);
            ISolrResponseParser <NamedList, QueryResults <DataRow> > solrResponseParser = new BinaryQueryResultsParser <DataRow>(objectDeserializeTable);
            BinaryHighlightingParser binaryHighlightingParser = new BinaryHighlightingParser();
            IDictionary <string, IDictionary <string, IList <string> > > highlight = binaryHighlightingParser.Parse(namedList);

            objectDeserializeTable.Highlight = highlight;
            QueryResults <DataRow> queryResults = solrResponseParser.Parse(namedList);

            recordCount = queryResults.NumFound;
            DataSet   dataSet   = new DataSet();
            DataTable dataTable = objectDeserializeTable.CreateDataTable();

            foreach (DataRow current in queryResults)
            {
                dataTable.Rows.Add(current.ItemArray);
            }
            dataSet.Tables.Add(dataTable);
            DataTable dataTable2 = new DataTable();

            dataTable2.TableName = "RecordCount";
            dataTable2.Columns.Add("RecordCount", typeof(long));
            DataRow dataRow = dataTable2.NewRow();

            dataRow["RecordCount"] = recordCount;
            dataTable2.Rows.Add(dataRow);
            dataSet.Tables.Add(dataTable2);
            return(dataSet);
        }
Ejemplo n.º 3
0
        public static IEnumerable <T> ParserResults <T>(this NamedList namedList, string fields, out long recordCount, string tableName = "") where T : class, new()
        {
            ObjectDeserializeT <T> objectDeserializeT = new ObjectDeserializeT <T>(tableName, fields);
            ISolrResponseParser <NamedList, QueryResults <T> > solrResponseParser = new BinaryQueryResultsParser <T>(objectDeserializeT);
            BinaryHighlightingParser binaryHighlightingParser = new BinaryHighlightingParser();
            IDictionary <string, IDictionary <string, IList <string> > > highlight = binaryHighlightingParser.Parse(namedList);

            objectDeserializeT.Highlight = highlight;
            QueryResults <T> queryResults = solrResponseParser.Parse(namedList);

            recordCount = queryResults.NumFound;
            return(queryResults);
        }
Ejemplo n.º 4
0
        private IEnumerable <GroupResultInfo <T> > QueryGroupResultsParseT(string fields, NamedList namedList, string highlightFields, out int matchesCount)
        {
            ObjectDeserializeT <T> objectDeserializeT = new ObjectDeserializeT <T>(this._TableName, fields);

            matchesCount = 0;
            ISolrResponseParser <NamedList, IList <GroupQueryResults <T> > > solrResponseParser = new BinaryGroupQueryResultsParser <T>(objectDeserializeT);

            if (!string.IsNullOrWhiteSpace(highlightFields))
            {
                BinaryHighlightingParser binaryHighlightingParser = new BinaryHighlightingParser();
                IDictionary <string, IDictionary <string, IList <string> > > highlight = binaryHighlightingParser.Parse(namedList);
                objectDeserializeT.Highlight = highlight;
            }
            List <GroupResultInfo <T> >        list  = new List <GroupResultInfo <T> >();
            IList <GroupQueryResults <T> >     list2 = solrResponseParser.Parse(namedList);
            IEnumerable <GroupResultInfo <T> > result;

            if (list2 == null || list2.Count == 0)
            {
                result = list;
            }
            else
            {
                NamedList namedList2 = (NamedList)namedList.Get("grouped");
                int       num        = 0;
                foreach (GroupQueryResults <T> current in list2)
                {
                    matchesCount = current.Matches;
                    NamedList namedList3 = (NamedList)namedList2.GetVal(num);
                    object    obj        = namedList3.Get("ngroups");
                    if (obj != null)
                    {
                        matchesCount = Convert.ToInt32(obj);
                    }
                    foreach (GroupQueryResult <T> current2 in current.Groups)
                    {
                        list.Add(new GroupResultInfo <T>
                        {
                            Data         = current2.QueryResults,
                            RecordCount  = current2.QueryResults.NumFound,
                            MatchesCount = current.Matches,
                            GroupValue   = current2.GroupValue
                        });
                    }
                    num++;
                }
                result = list;
            }
            return(result);
        }
Ejemplo n.º 5
0
        private IEnumerable <T> QueryResultsParseT(string fields, NamedList namedList, string highlightFields, out long recordCount)
        {
            ObjectDeserializeT <T> objectDeserializeT = new ObjectDeserializeT <T>(this._TableName, fields);
            ISolrResponseParser <NamedList, QueryResults <T> > solrResponseParser = new BinaryQueryResultsParser <T>(objectDeserializeT);

            if (!string.IsNullOrWhiteSpace(highlightFields))
            {
                BinaryHighlightingParser binaryHighlightingParser = new BinaryHighlightingParser();
                IDictionary <string, IDictionary <string, IList <string> > > highlight = binaryHighlightingParser.Parse(namedList);
                objectDeserializeT.Highlight = highlight;
            }
            QueryResults <T> queryResults = solrResponseParser.Parse(namedList);

            recordCount = queryResults.NumFound;
            return(queryResults);
        }
Ejemplo n.º 6
0
        public static FacetResult <T> ParserFacetResults <T>(this NamedList namedList, string fields, out long recordCount, string tableName = "") where T : class, new()
        {
            ObjectDeserializeT <T> objectDeserializeT = new ObjectDeserializeT <T>(tableName, fields);
            ISolrResponseParser <NamedList, QueryResults <T> > solrResponseParser = new BinaryQueryResultsParser <T>(objectDeserializeT);
            BinaryHighlightingParser binaryHighlightingParser = new BinaryHighlightingParser();
            IDictionary <string, IDictionary <string, IList <string> > > highlight = binaryHighlightingParser.Parse(namedList);

            objectDeserializeT.Highlight = highlight;
            QueryResults <T>        queryResults                      = solrResponseParser.Parse(namedList);
            BinaryFacetFieldsParser binaryFacetFieldsParser           = new BinaryFacetFieldsParser();
            IDictionary <string, IList <FacetField> >     dictionary  = binaryFacetFieldsParser.Parse(namedList);
            IDictionary <string, IList <FacetFieldInfo> > dictionary2 = new Dictionary <string, IList <FacetFieldInfo> >();

            if (dictionary != null && dictionary.Count > 0)
            {
                foreach (KeyValuePair <string, IList <FacetField> > current in dictionary)
                {
                    List <FacetFieldInfo> list = new List <FacetFieldInfo>();
                    foreach (FacetField current2 in current.Value)
                    {
                        list.Add(new FacetFieldInfo
                        {
                            Name  = current2.Name,
                            Count = current2.Count
                        });
                    }
                    dictionary2.Add(current.Key, list);
                }
            }
            FacetResult <T> facetResult = new FacetResult <T>();

            facetResult.Data  = queryResults;
            facetResult.Facet = dictionary2;
            recordCount       = queryResults.NumFound;
            return(facetResult);
        }