public ActionResult AdvStructureSearch(string query, string exactsearch, string stereo, GridDescriptor request) { System.Web.HttpContext.Current.Session["AdvancedSearchFilter"] = null; var tmp = BreadcrumbNavigationGetSet(); AdvSearchFiltersAll filters = new AdvSearchFiltersAll(); if (filters.StructureSearch == null) { filters.StructureSearch = new AdvStructureSearch(); } filters.StructureSearch.Query = query; filters.StructureSearch.Exactsearch = exactsearch; filters.StructureSearch.Stereo = stereo; filters = BreadcrumbNavigationGetSet(filters); StringBuilder sb = new StringBuilder(524288); byte[] bytesData = Encoding.ASCII.GetBytes("query=" + query + ";exactsearch=" + exactsearch + ";stereo=" + stereo + "\0"); int result = StructureSearch(bytesData, sb, sb.Capacity); string recordIds = sb.Replace(";", ",").ToString().Trim().TrimEnd(','); ViewBag.ErrorMsg = "result: " + result + "sb: " + sb; BaseSearchModel model = new BaseSearchModel(); model.IsStructureSearch = true; if (request.Pager == null) { request = new GridDescriptor(new SortDescriptor() { PropertyName = "Name", Order = SortOrder.Ascending }); } model.Descriptor = request; //kada proradi raskomentarisati if (!string.IsNullOrEmpty(recordIds) && result > 0) { model.ListOfMaterials = _searchResultsBinder.GetResultsStructureAdvSearch(recordIds, request, materialContextUow); } SearchResultsCondition filterModel = new SearchResultsCondition(); filterModel.FullText = ""; filterModel.ShowPropertiesFilters = false; filterModel.FromBrowse = false; filterModel.FromAdvanced = true; model.Filter = filterModel; ModelState.Clear(); return(View("AdvSearchResults", model)); }
public JsonResult ApplyAdvSearchFilters(AdvSearchFiltersAll filters, GridDescriptor request) { // Check for null valuse in conditionFilters foreach (AdvSearchFilters f in filters.AllFilters) { if (f.PropertyConditions == null) { f.PropertyConditions = new List <PropertyConditionModel>(); } } filters = BreadcrumbNavigationGetSet(filters); return(Json(ResponseStatus.Success, new { url = Url.Action("AdvSearchResults", "AdvSearch") }, JsonRequestBehavior.AllowGet)); }
private AdvSearchFiltersAll GenerateFilters() { BreadcrumbNavigation nav = (BreadcrumbNavigation)System.Web.HttpContext.Current.Session["Navigation"]; if (nav == null) { nav = new BreadcrumbNavigation(); } AdvancedSearchNav adv = nav.GetOrderedItems().Where(n => n.NavigableID == "AdvancedSearch").FirstOrDefault() as AdvancedSearchNav; IList <PropertyUnitModel> units = (IList <PropertyUnitModel>)adv.PageData; AdvSearchFiltersAll ret = new AdvSearchFiltersAll() { AllFilters = new List <AdvSearchFilters>() }; foreach (var item in units) { AdvSearchFilters fil = new AdvSearchFilters() { propertyId = item.PropertyID, propertyName = item.PropertyName, propertyType = item.PropertyType, unitId = item.SelectedUnit }; if (item.SelectedUnit != -1) { fil.unitName = item.Units.FirstOrDefault(i => i.UnitKey == item.SelectedUnit).UnitLabel; } //fil.valueFrom = Decimal.Parse(item.ValueFrom); //fil.valueTo = Decimal.Parse(item.ValueTo); //ret.AllFilters.Add(fil); decimal vFrom; bool isDecimalFrom = decimal.TryParse(item.ValueFrom, out vFrom); vFrom = isDecimalFrom ? vFrom : 0; ; decimal vTo; bool isDecimalTo = decimal.TryParse(item.ValueFrom, out vTo); vTo = isDecimalTo ? vTo : 0; ; fil.valueFrom = vFrom; fil.valueTo = vTo; ret.AllFilters.Add(fil); } return(ret); }
public JsonResult GetFilters(SearchFilters filters) { SearchResultsCondition filterModel = GetFiltersModel(filters); IDictionary <string, object> allFilters = BreadcrumbNavigationGetSet(filters, null); AdvSearchFiltersAll advFilters = new AdvSearchFiltersAll(); if (allFilters.ContainsKey("advFilters")) { advFilters = (AdvSearchFiltersAll)allFilters["advFilters"]; } IList <PropertyUnitModel> units = new List <PropertyUnitModel>(); if (advFilters != null && advFilters.AllFilters != null) { foreach (var item in advFilters.AllFilters) { var pUnits = materialContextUow.PropertyUnits.AllAsNoTracking.Where(n => n.PropertyID == item.propertyId).ToList(); PropertyUnitModel pum = new PropertyUnitModel() { PropertyType = item.propertyType, UniqueID = Guid.NewGuid().ToString("N"), PropertyID = item.propertyId, PropertyName = item.propertyName, Units = new List <UnitModel>() }; foreach (var u in pUnits.Where(i => i.UnitKey != null)) { pum.Units.Add(new UnitModel() { Factor = (double)u.Factor, Metric = (bool)u.Metric, Offset = (double)u.Offset, UnitKey = (int)u.UnitKey, UnitLabel = u.UnitLabel }); } pum.SelectedUnit = item.unitId; pum.SelectedBinary = item.binaryOperators; pum.SelectedLogical = item.logicalOperators; pum.ValueFrom = item.valueFrom_orig == null ? "" : item.valueFrom_orig.ToString(); pum.ValueTo = item.valueTo_orig == null ? "" : item.valueTo_orig.ToString(); units.Add(pum); } } return(Json(ResponseStatus.Success, new { showTitle = units.Count > 0 ? true : false, dataSearch = RenderPartialViewToString("FiltersContainerAdvProp", filterModel), dataAdv = RenderPartialViewToString("SearchConditionItemContainer", units) }, JsonRequestBehavior.AllowGet)); }
public JsonResult ApplyFilters(SearchFilters filters, AdvSearchFiltersAll advFilters, string classIds, int reset = 0) { if (classIds == "") { Session["ClassificationIds"] = ""; } BaseSearchModel model = new BaseSearchModel(); IDictionary <string, object> allFilters = BreadcrumbNavigationGetSet(filters, advFilters, false, classIds); filters = (SearchFilters)allFilters["filters"]; advFilters = (AdvSearchFiltersAll)allFilters["advFilters"]; if (reset == 1) { Session["ClassificationIds"] = ""; advFilters = null; classIds = ""; } model = SearchResults(filters, classIds, advFilters); SearchResultsCondition filterModel = new SearchResultsCondition(); filterModel.ClasificationId = filters.ClasificationId; filterModel.ClasificationTypeId = filters.ClasificationTypeId; filterModel.PropertyClasificationId = filters.PropertyClasificationId; filterModel.PropertyClasificationTypeId = filters.PropertyClasificationTypeId; filterModel.FullText = filters.filter; filterModel.ShowPropertiesFilters = false; filterModel.FromBrowse = filters.FromBrowse; filterModel.SelectedSource = filters.Source; model.Filter = filterModel; System.Web.HttpContext.Current.Session["AdvancedSearchFilter"] = advFilters; ModelState.Clear(); return(Json(ResponseStatus.Success, RenderPartialViewToString("ResultsContainer", model))); }
public AdvSearchFiltersAll BreadcrumbNavigationGetSet(AdvSearchFiltersAll filters) { BreadcrumbNavigation nav = (BreadcrumbNavigation)System.Web.HttpContext.Current.Session["Navigation"]; if (nav == null) { nav = new BreadcrumbNavigation(); } if (nav.Contains("Exporter")) { nav.Pop(); } if (nav.Contains("Comparison")) { nav.Pop(); } if (nav.Contains("MaterialDetails1")) { nav.Pop(); } if (nav.Contains("Subgroups")) { nav.Pop(); } if (nav.Contains("BrowseFacets")) { nav.Pop(); } if (nav.Contains("BrowseHome")) { nav.Pop(); } AdvancedSearchNav adv = nav.GetOrderedItems().Where(n => n.NavigableID == "AdvancedSearch").FirstOrDefault() as AdvancedSearchNav; if (adv == null) { adv.IsVisible = true; adv = new AdvancedSearchNav(); } IList <PropertyUnitModel> units = new List <PropertyUnitModel>(); foreach (var item in nav.GetOrderedItems().Where(n => n.NavigableID != "HomePage" && n.NavigableID != "AdvancedSearch")) { item.IsVisible = false; } if (nav.Contains("FullSearch")) { FullSearch fs = nav.GetOrderedItems().Where(n => n.NavigableID == "FullSearch").FirstOrDefault() as FullSearch; fs.IsVisible = false; fs.PageData = null; } AdvancedSearchResults res = nav.GetOrderedItems().Where(n => n.NavigableID == "AdvancedSearchResults").FirstOrDefault() as AdvancedSearchResults; if (res == null) { AdvancedSearchResults hp = new AdvancedSearchResults(); hp.PageData = filters; nav.Push(hp); } else { if (filters == null || (filters != null && filters.AllFilters == null && filters.StructureSearch == null) || (filters != null && filters.AllFilters != null && filters.AllFilters.Count == 0 && filters.StructureSearch == null) ) { string selectedSource = filters.SelectedSource; filters = res.PageData as AdvSearchFiltersAll; if (selectedSource != null) { filters.SelectedSource = selectedSource; } } else { res.PageData = filters; res.IsVisible = true; nav.Push(res); } } nav.LastNavigable = "AdvancedSearchResults"; if (filters != null && filters.AllFilters != null) { foreach (var item in filters.AllFilters) { var pUnits = materialContextUow.PropertyUnits.AllAsNoTracking.Where(n => n.PropertyID == item.propertyId).ToList(); PropertyUnitModel pum = new PropertyUnitModel() { PropertyType = item.propertyType, UniqueID = Guid.NewGuid().ToString("N"), PropertyID = item.propertyId, PropertyName = item.propertyName, IsPropertyConditionsActive = item.isPropertyConditionsActive, Units = new List <UnitModel>() }; foreach (var u in pUnits.Where(i => i.UnitKey != null)) { pum.Units.Add(new UnitModel() { Factor = (double)u.Factor, Metric = (bool)u.Metric, Offset = (double)u.Offset, UnitKey = (int)u.UnitKey, UnitLabel = u.UnitLabel }); } pum.SelectedUnit = item.unitId; pum.SelectedBinary = item.binaryOperators; pum.SelectedLogical = item.logicalOperators; pum.ValueFrom = item.valueFrom_orig == null ? "" : item.valueFrom_orig.ToString(); pum.ValueTo = item.valueTo_orig == null ? "" : item.valueTo_orig.ToString(); // Fill property conditions pum.PropertyConditions = new List <PropertyConditionModel>(); foreach (var cond in item.PropertyConditions) { PropertyConditionModel oneCondition = new PropertyConditionModel() { Condition = new AdvSearchPropertyConditions() { PropertyID = cond.Condition.PropertyID, X_label = cond.Condition.X_label, UnitGroup = cond.Condition.UnitGroup }, SelectedLogical = cond.SelectedLogical, ValueFrom = cond.ValueFrom, ValueTo = cond.ValueTo }; oneCondition.FillUnits(); pum.PropertyConditions.Add(oneCondition); } units.Add(pum); } adv.PageData = units; } System.Web.HttpContext.Current.Session["Navigation"] = nav; return(filters); }
public JsonResult ApplyPager(GridDescriptor request) { BreadcrumbNavigation nav = (BreadcrumbNavigation)System.Web.HttpContext.Current.Session["Navigation"]; if (nav == null) { nav = new BreadcrumbNavigation(); } AdvSearchFiltersAll filters = new AdvSearchFiltersAll(); AdvancedSearchResults res = nav.GetOrderedItems().Where(n => n.NavigableID == "AdvancedSearchResults").FirstOrDefault() as AdvancedSearchResults; if (res != null) { filters = res.PageData as AdvSearchFiltersAll; } nav.LastNavigable = "AdvancedSearchResults"; System.Web.HttpContext.Current.Session["Navigation"] = nav; BaseSearchModel model = new BaseSearchModel(); if (request.Pager == null) { request = new GridDescriptor(new SortDescriptor() { PropertyName = "Name", Order = SortOrder.Ascending }); } model.Descriptor = request; if (filters.StructureSearch != null) { StringBuilder sb = new StringBuilder(65536); byte[] bytesData = Encoding.ASCII.GetBytes("query=" + filters.StructureSearch.Query + ";exactsearch=" + filters.StructureSearch.Exactsearch + ";stereo=" + filters.StructureSearch.Stereo + "\0"); var result = StructureSearch(bytesData, sb, sb.Capacity); string recordIds = sb.Replace(";", ",").ToString().Trim().TrimEnd(','); if (!string.IsNullOrEmpty(recordIds)) { model.ListOfMaterials = _searchResultsBinder.GetResultsStructureAdvSearch(recordIds, request, materialContextUow); } model.IsStructureSearch = true; } else { model.ListOfMaterials = _searchResultsBinder.GetResultsAdvSearch(filters, request, materialContextUow); } SearchResultsCondition filterModel = new SearchResultsCondition(); //filterModel.ClasificationId = filters.ClasificationId; //filterModel.ClasificationTypeId = filters.ClasificationTypeId; filterModel.FullText = ""; filterModel.ShowPropertiesFilters = false; filterModel.FromBrowse = false; filterModel.FromAdvanced = true; // add Sources to model filterModel.Sources = materialContextUow.Sources.AllAsNoTracking.OrderBy(m => m.Id).ThenBy(n => n.Name).ToList(); filterModel.SelectedSource = filters.SelectedSource; model.Filter = filterModel; //BreadcrumbNavigationGetSet(filters); return(Json(ResponseStatus.Success, RenderPartialViewToString("AdvResultsContainer", model), JsonRequestBehavior.AllowGet)); }
public JsonResult ApplyAdvSearchSource(AdvSearchFiltersAll filters, GridDescriptor request) { filters = BreadcrumbNavigationGetSet(filters); return(Json(ResponseStatus.Success, new { url = Url.Action("AdvSearchResults", "AdvSearch") }, JsonRequestBehavior.AllowGet)); }
public IDictionary <string, object> BreadcrumbNavigationGetSet(SearchFilters filters, AdvSearchFiltersAll advFilters, bool browse = false, string classIds = "") { BreadcrumbNavigation nav = (BreadcrumbNavigation)System.Web.HttpContext.Current.Session["Navigation"]; if (nav == null) { nav = new BreadcrumbNavigation(); } if (nav.Contains("Exporter")) { nav.Pop(); } if (nav.Contains("Comparison")) { nav.Pop(); } if (nav.Contains("MaterialDetails1")) { nav.Pop(); } if (nav.Contains("Subgroups")) { nav.Pop(); } IDictionary <string, object> allFilters = new Dictionary <string, object>(); foreach (var item in nav.GetOrderedItems().Where(n => n.NavigableID != "HomePage")) { item.IsVisible = false; } if (browse) { allFilters.Add("filters", filters); nav.GetOrderedItems().Where(n => n.NavigableID == "BrowseHome").FirstOrDefault().IsVisible = true; BrowseFacets bf = nav.GetOrderedItems().Where(n => n.NavigableID == "BrowseFacets").FirstOrDefault() as BrowseFacets; if (bf == null) { bf = new BrowseFacets(); bf.PageData = allFilters; } else { if (filters.ClasificationId == 0) { allFilters = (Dictionary <string, object>)bf.PageData; } else { bf.PageData = allFilters; } } bf.IsVisible = true; nav.LastNavigable = "BrowseFacets"; nav.Push(bf); } else { allFilters.Add("filters", filters); allFilters.Add("advFilters", advFilters); if (nav.Contains("AdvancedSearch")) { AdvancedSearchNav asn = nav.GetOrderedItems().Where(n => n.NavigableID == "AdvancedSearch").FirstOrDefault() as AdvancedSearchNav; asn.PageData = null; asn.IsVisible = false; } if (nav.Contains("AdvancedSearchResults")) { AdvancedSearchResults asn = nav.GetOrderedItems().Where(n => n.NavigableID == "AdvancedSearchResults").FirstOrDefault() as AdvancedSearchResults; asn.PageData = null; asn.IsVisible = false; } FullSearch fs = nav.GetOrderedItems().Where(n => n.NavigableID == "FullSearch").FirstOrDefault() as FullSearch; if (fs == null) { HomePage hp = new HomePage(); hp.PageData = 0; ViewBag.TabSelected = hp.PageData; nav.LastNavigable = "HomePage"; hp.IsVisible = true; nav.Push(hp); fs = new FullSearch(); fs.PageData = allFilters; } else { if (filters.filter == null && (filters.Source == null || filters.Source == "0") && (advFilters == null || advFilters.AllFilters == null)) { allFilters = (Dictionary <string, object>)fs.PageData; } else { fs.PageData = allFilters; } if (!string.IsNullOrWhiteSpace(classIds)) { Session["ClassificationIds"] = classIds; } } fs.IsVisible = true; nav.LastNavigable = "FullSearch"; nav.Push(fs); } System.Web.HttpContext.Current.Session["Navigation"] = nav; return(allFilters); }
private BaseSearchModel SearchResults(SearchFilters filters, string classIds, AdvSearchFiltersAll advFilters, GridDescriptor grd = null) { BaseSearchModel model; if (grd == null) { model = _searchResultsBinder.GetResults(filters, new GridDescriptor(new SortDescriptor() { PropertyName = "Name", Order = SortOrder.Ascending }), materialContextUow, classIds, advFilters); } else { model = _searchResultsBinder.GetResults(filters, grd, materialContextUow, classIds, advFilters); } return(model); }
public IEnumerable <int> GetMaterialsByAdvancedSearch(bool withTracking, AdvSearchFiltersAll filters, string sessionId, IQueryable <EquivalentProperty> propIds, IQueryable <EquivalentMaterial> matIds) { //string fiedList = "[MaterialID], [PropertyID], [Value], [ValueMin], [ValueMax]"; string fieldList = "[MaterialID], 0 AS [PropertyID], CAST(1.0 as FLOAT) AS [Value], CAST(2.0 AS FLOAT) AS [ValueMin], CAST(3.0 AS FLOAT) AS [ValueMax]"; string fieldListMat = "[ID] AS [MaterialID], 0 AS [PropertyID], CAST(1.0 as FLOAT) AS [Value], CAST(2.0 AS FLOAT) AS [ValueMin], CAST(3.0 AS FLOAT) AS [ValueMax]"; //StringBuilder sb = new StringBuilder(); //sb.Append(";"); int optCounter = 0; int argCounter = -1; IList <object> allArgs = new List <object>(); IList <AdvSearchSqlQueryDef> AdvSearchSqlQueryDefs = new List <AdvSearchSqlQueryDef>(); string queryToAppend = ""; foreach (AdvSearchFilters f in filters.AllFilters) { // To return the data in Set A that doesn’t overlap with B, use A EXCEPT B. // To return only the data that overlaps in the two sets, use A INTERSECT B. // To return the data in Set B that doesn’t overlap with A, use B EXCEPT A. // To return the data in all three areas without duplicates, use A UNION B. // To return the data in all three areas, including duplicates, use A UNION ALL B. // To return the data in the non-overlapping areas of both sets, use (A UNION B) except (A INTERSECT B), or perhaps (A EXCEPT B) UNION (B EXCEPT A) // // If EXCEPT or INTERSECT is used together with other operators in an expression, it is evaluated in the context of the following precedence: // 1. Expressions in parentheses // 2. The INTERSECT operator // 3. EXCEPT and UNION evaluated from left to right based on their position in the expression // // Limitation: Max number of parameters for T-SQL command is 2100! AdvSearchSqlQueryDef oneAdvSearchSqlQueryDef = new AdvSearchSqlQueryDef() { Filter = f }; optCounter++; queryToAppend = ""; IList <object> oneArgs = new List <object>(); switch (f.propertyType) { case PropertyType.NotDefined: break; case PropertyType.Material: oneAdvSearchSqlQueryDef.Operator = f.binaryOperators; queryToAppend = ""; // reset first binary operator to AND f.binaryOperators = (optCounter == 1 ? BinaryOperators.And : f.binaryOperators); switch (f.binaryOperators) { case BinaryOperators.NotDefined: break; case BinaryOperators.And: //sb.Append(optCounter > 1 ? " INTERSECT " : ""); queryToAppend = PrepareMaterial(f, fieldListMat, ref argCounter, ref allArgs, ref oneArgs); break; case BinaryOperators.Or: //sb.Append(optCounter > 1 ? " UNION " : ""); queryToAppend = PrepareMaterial(f, fieldListMat, ref argCounter, ref allArgs, ref oneArgs); break; case BinaryOperators.Not: //sb.Append(optCounter > 1 ? " EXCEPT " : ""); queryToAppend = PrepareMaterial(f, fieldListMat, ref argCounter, ref allArgs, ref oneArgs); break; default: break; } //sb.Append(queryToAppend); oneAdvSearchSqlQueryDef.Query = queryToAppend; break; case PropertyType.Property: oneAdvSearchSqlQueryDef.Operator = f.binaryOperators; queryToAppend = ""; // reset first binary operator to AND f.binaryOperators = (optCounter == 1 ? BinaryOperators.And : f.binaryOperators); switch (f.binaryOperators) { case BinaryOperators.NotDefined: break; case BinaryOperators.And: //sb.Append(optCounter > 1 ? " INTERSECT " : ""); queryToAppend = prepareLogicalOperator(f, fieldList, ref argCounter, ref allArgs, ref oneArgs); break; case BinaryOperators.Or: //sb.Append(optCounter > 1 ? " UNION " : ""); queryToAppend = prepareLogicalOperator(f, fieldList, ref argCounter, ref allArgs, ref oneArgs); break; case BinaryOperators.Not: //sb.Append(optCounter > 1 ? " EXCEPT " : ""); queryToAppend = prepareLogicalOperator(f, fieldList, ref argCounter, ref allArgs, ref oneArgs); break; default: break; } //sb.Append(queryToAppend); oneAdvSearchSqlQueryDef.Query = queryToAppend; break; default: break; } oneAdvSearchSqlQueryDef.Args = oneArgs; AdvSearchSqlQueryDefs.Add(oneAdvSearchSqlQueryDef); } // Add source condition int sourceId = -1; int databookId = -1; if (filters.SelectedSource != null && filters.SelectedSource != "0" /* "0" = All */) { string[] ids = filters.SelectedSource.Split(','); sourceId = ids[0] != null?int.Parse(ids[0]) : -1; databookId = ids[1] != null?int.Parse(ids[1]) : -1; AdvSearchFilters fSource = new AdvSearchFilters(); AdvSearchSqlQueryDef oneAdvSearchSqlQueryDefSource = new AdvSearchSqlQueryDef(); IList <object> oneArgsSource = new List <object>(); if (databookId == 0 && sourceId != 0 && sourceId != -1) { fSource = new AdvSearchFilters() { propertyType = PropertyType.Material, binaryOperators = BinaryOperators.And, propertyId = sourceId, propertyName = "SOURCE:" }; queryToAppend = PrepareMaterial(fSource, fieldListMat, ref argCounter, ref allArgs, ref oneArgsSource); } else if (databookId != 0 && databookId != -1 && sourceId != 0 && sourceId != -1) { fSource = new AdvSearchFilters() { propertyType = PropertyType.Material, binaryOperators = BinaryOperators.And, propertyId = databookId, propertyName = "DATABOOK:" }; queryToAppend = PrepareMaterial(fSource, fieldListMat, ref argCounter, ref allArgs, ref oneArgsSource); } oneAdvSearchSqlQueryDefSource.Filter = fSource; oneAdvSearchSqlQueryDefSource.Query = queryToAppend; oneAdvSearchSqlQueryDefSource.Args = oneArgsSource; oneAdvSearchSqlQueryDefSource.Operator = fSource.binaryOperators; AdvSearchSqlQueryDefs.Add(oneAdvSearchSqlQueryDefSource); } // (with TM data) int nextStartIndex = 0; int queryCounter = 0; IList <EquivalentMaterial> matIdsM = matIds.Where(m => m.SourceId == 2).ToList(); IList <EquivalentMaterial> matIdsP = matIds.Where(m => m.SourceId == 3).ToList(); IList <EquivalentProperty> propIdsM = propIds.Where(p => p.SourceId == 2).ToList(); IList <EquivalentProperty> propIdsP = propIds.Where(p => p.SourceId == 3).ToList(); IService service = new TotalMateriaService(); IPlusService servicePLUS = new TMPlusService(); IEnumerable <int> dsAll = null; foreach (AdvSearchSqlQueryDef qDef in AdvSearchSqlQueryDefs) { queryCounter++; // Prepare arguments for SQL Query (renumerate them) for (int i = 0; i < qDef.Args.Count(); i++) { qDef.Query = qDef.Query.Replace("{" + (nextStartIndex).ToString() + "}", "{" + i.ToString() + "}"); nextStartIndex++; } ///////// string cmdText = qDef.Query; object[] arg = qDef.Args.ToArray(); IEnumerable <int> ds = DataSet.SqlQuery(cmdText, arg).Select(m => m.MaterialID); // Call Web service for TM property data and make UNION with ds from the EMS dabase if ((databookId == 0 || databookId == -1) && filters.IsChemical == false) { if (qDef.Filter.propertyType == PropertyType.Property) { // SELECT SourcePropertyId FROM [EquivalentProperty] WHERE [EquivalentProperty].SourceId=2 AND [EquivalentProperty].PropertyId = propertyId int propertyId = qDef.Filter.propertyId; if (sourceId == 2 || sourceId == -1) { // // Step 1. Metals // EquivalentProperty epM = propIdsM.Where(p => p.PropertyId == propertyId).FirstOrDefault(); // Call service only if relation is defined in the equivalent table if (epM != null) { //int pIdMetalI = propIdsM.Where(p => p.PropertyId == propertyId).FirstOrDefault().SourcePropertyId; int pIdMetalI = epM.SourcePropertyId; IList <AdvSearchFilters> filtersForService = new List <AdvSearchFilters>(); //Make object clone and do c; See SearchResultsBinder.cs filtersForService.Add(new AdvSearchFilters() { propertyType = qDef.Filter.propertyType, logicalOperators = qDef.Filter.logicalOperators, binaryOperators = qDef.Filter.binaryOperators, propertyId = pIdMetalI, /* !!! calling byRef, original value is changed !!! */ propertyName = qDef.Filter.propertyName, valueFrom = qDef.Filter.valueFrom, valueTo = qDef.Filter.valueTo, valueFrom_orig = qDef.Filter.valueFrom_orig, valueTo_orig = qDef.Filter.valueTo_orig, unitId = qDef.Filter.unitId, unitName = qDef.Filter.unitName }); // Service returns list of SourceMaterialId IList <int> listOfTMMetalIds = service.GetMaterialIdsForAdvSearchPropertiesFromService(sessionId, new AdvSearchFiltersAll() { AllFilters = filtersForService }); // Find material IDs in EMS database IList <int> res2M = (from u1 in matIdsM join u2 in listOfTMMetalIds on u1.SourceMaterialId equals(int) u2 select u1.MaterialId).ToList(); ds = ds.Concat(res2M).Distinct(); } // End of Call service only if relation is defined in the equivalent table // // End of Step 1. Metals } //if (sourceId == 3 || sourceId == -1) if ((sourceId == 3 || sourceId == -1) && filters.IsChemical == false) { // // Step 2. PLUS // EquivalentProperty epP = propIdsP.Where(p => p.PropertyId == propertyId).FirstOrDefault(); // Call service only if relation is defined in the equivalent table if (epP != null) { //int pIdMetalI = propIdsM.Where(p => p.PropertyId == propertyId).FirstOrDefault().SourcePropertyId; int pIdPlusI = epP.SourcePropertyId; IList <AdvSearchFilters> filtersForService = new List <AdvSearchFilters>(); //Make object clone and do c; See SearchResultsBinder.cs filtersForService.Add(new AdvSearchFilters() { propertyType = qDef.Filter.propertyType, logicalOperators = qDef.Filter.logicalOperators, binaryOperators = qDef.Filter.binaryOperators, propertyId = pIdPlusI, /* !!! calling byRef, original value is changed !!! */ propertyName = qDef.Filter.propertyName, valueFrom = qDef.Filter.valueFrom, valueTo = qDef.Filter.valueTo, valueFrom_orig = qDef.Filter.valueFrom_orig, valueTo_orig = qDef.Filter.valueTo_orig, unitId = qDef.Filter.unitId, unitName = qDef.Filter.unitName }); // Service returns list of SourceMaterialId IList <int> listOfTMPLUSIds = servicePLUS.GetMaterialIdsForAdvSearchPropertiesFromServicePLUS(sessionId, new AdvSearchFiltersAll() { AllFilters = filtersForService }); // Find material IDs in EMS database IList <int> res2P = (from u1 in matIdsP join u2 in listOfTMPLUSIds on u1.SourceMaterialId equals(int) u2 select u1.MaterialId).ToList(); ds = ds.Concat(res2P).Distinct(); } // End of Call service only if relation is defined in the equivalent table //ds = ds.Concat(res2P).Distinct(); // // End of Step 2. PLUS } } // End of Call Web service } if (!withTracking) { if (queryCounter == 1) { dsAll = ds; } else { switch (qDef.Operator) { case BinaryOperators.NotDefined: break; case BinaryOperators.And: // INTERSECT dsAll = dsAll.Intersect(ds); break; case BinaryOperators.Or: // UNION dsAll = dsAll.Union(ds); break; case BinaryOperators.Not: // EXCEPT dsAll = dsAll.Except(ds); break; default: break; } } } } return(dsAll); }
public IList <SampleMaterialModel> GetResultsAdvSearch(AdvSearchFiltersAll filters, GridDescriptor request, IMaterialsContextUow context) { IList <SampleMaterialModel> retList = new List <SampleMaterialModel>(); string sessionId = System.Web.HttpContext.Current.Session["TotalMateriaSession"].ToString(); IQueryable <EquivalentProperty> propIds = context.EquivalentProperties.AllAsNoTracking; IQueryable <EquivalentMaterial> matIds = context.EquivalentMaterials.AllAsNoTracking; IEnumerable <int> materialIds = context.AdvSearchResults.GetMaterialsByAdvancedSearch(false, filters, sessionId, propIds, matIds); // Check for Taxonomy and find filter levels bool isTaxonomy = false; int level = 0; int levelId = 0; int taxonomyCounter = 0; IList <Tuple <int, int, BinaryOperators> > levels = new List <Tuple <int, int, BinaryOperators> >(); foreach (AdvSearchFilters f in filters.AllFilters) { if (f.propertyName.ToUpper().StartsWith("TYPE:")) { level = 1; taxonomyCounter++; levelId = f.propertyId; levels.Add(new Tuple <int, int, BinaryOperators>(level, levelId, f.binaryOperators)); } if (f.propertyName.ToUpper().StartsWith("CLASS:")) { level = 2; taxonomyCounter++; levelId = f.propertyId; levels.Add(new Tuple <int, int, BinaryOperators>(level, levelId, f.binaryOperators)); } if (f.propertyName.ToUpper().StartsWith("SUBCLASS:")) { level = 3; taxonomyCounter++; levelId = f.propertyId; levels.Add(new Tuple <int, int, BinaryOperators>(level, levelId, f.binaryOperators)); } if (f.propertyName.ToUpper().StartsWith("GROUP:")) { level = 4; taxonomyCounter++; levelId = f.propertyId; levels.Add(new Tuple <int, int, BinaryOperators>(level, levelId, f.binaryOperators)); } } isTaxonomy = (level > 0 && taxonomyCounter == 1); IEnumerable <int> matVisibleIds = materialIds.Page(request.Pager); if (isTaxonomy == false) { var results = context.FullTextSearch.GetMaterialsByMaterialIds(matVisibleIds); retList = results.Select(m => new SampleMaterialModel() { Id = m.Id, Name = m.material_designation, TypeName = m.material_type, // level1 GroupName = m.material_group, // level2 ClassName = m.material_class, // level3 SubClassName = m.material_subClass // level4 //, //UNS = m.UNS, //CAS_RN = m.CAS_RN }).ToList(); } else { IEnumerable <MaterialTaxonomy> taxonomy = context.MaterialTaxonomyAll.AllAsNoTracking; //Only if levels contains one filter definition! foreach (Tuple <int, int, BinaryOperators> l in levels) { if (l.Item1 == 1) { taxonomy = taxonomy.Where(t => t.Level1 == l.Item2); } else if (l.Item1 == 2) { taxonomy = taxonomy.Where(t => t.Level2 == l.Item2); } if (l.Item1 == 3) { taxonomy = taxonomy.Where(t => t.Level3 == l.Item2); } else if (l.Item1 == 4) { taxonomy = taxonomy.Where(t => t.Level4 == l.Item2); } } // Eval taxonomy page data and store it into memory IList <MaterialTaxonomy> lTaxonomy = (from t in taxonomy join m in matVisibleIds on t.ID equals m select t) .OrderBy(l => l.ID) .ThenBy(l1 => l1.Level1Name) .ThenByDescending(l4 => l4.Level4Name) .ThenByDescending(l3 => l3.Level3Name) .ThenByDescending(l2 => l2.Level2Name) .ToList(); // Fill final data for one page (take only first (because it is it is non-null for sure) element for each id in matVisibleIds) retList = new List <SampleMaterialModel>(); foreach (int mat in matVisibleIds) { MaterialTaxonomy mResult = lTaxonomy.Where(r => r.ID == mat).FirstOrDefault(); if (mResult != null) { retList.Add(new SampleMaterialModel() { Id = mResult.ID, Name = mResult.MaterialName, TypeName = mResult.Level1Name, GroupName = mResult.Level2Name, ClassName = mResult.Level3Name, SubClassName = mResult.Level4Name }); } } } return(retList); }
public BaseSearchModel GetResults(SearchFilters filters, GridDescriptor request, IMaterialsContextUow context, string classificationIds, AdvSearchFiltersAll advFilters) { if (string.IsNullOrWhiteSpace(classificationIds) && HttpContext.Current.Session["ClassificationIds"] != "") { classificationIds = (string)HttpContext.Current.Session["ClassificationIds"]; } BaseSearchModel model = new BaseSearchModel(); if (filters.filter == null) { filters.filter = ""; } IEnumerable <FullTextSearch> results = null; IEnumerable <MaterialTaxonomy> taxonomyResults = new List <MaterialTaxonomy>(); IEnumerable <MaterialTaxonomy> taxonomyResultsL1 = new List <MaterialTaxonomy>(); IEnumerable <MaterialTaxonomy> taxonomyResultsL2 = new List <MaterialTaxonomy>(); IEnumerable <MaterialTaxonomy> taxonomyResultsL3 = new List <MaterialTaxonomy>(); IEnumerable <MaterialTaxonomy> taxonomyResultsL4 = new List <MaterialTaxonomy>(); IEnumerable <int> taxonomyResultIds = new List <int>(); IList <int> typeIds = new List <int>(); IList <int> classIds = new List <int>(); IList <int> subclassIds = new List <int>(); IList <int> groupIds = new List <int>(); IList <int> resultIds = null; if (filters.filter != "") { results = context.FullTextSearch.GetMaterialsByFullTextSearch(false, filters.filter); resultIds = context.FullTextSearch.GetMaterialsIdsByFullTextSearch(filters.filter).ToList(); } else { if ((filters.FromBrowse && filters.ClasificationId != 0)) { taxonomyResults = context.MaterialTaxonomyAll.AllAsNoTracking; results = context.FullTextSearch.AllAsNoTracking; //resultIds = context.FullTextSearch.AllAsNoTracking.Select(c => c.Id).ToList(); resultIds = null; } else { results = new HashSet <FullTextSearch>(); resultIds = null; } } IList <string> allIds = new List <string>(); IList <int> classificationSelection = new List <int>(); if (classificationIds != null && classificationIds.Length > 0) { allIds = classificationIds.Split(',').ToList(); typeIds = new List <int>(); classIds = new List <int>(); subclassIds = new List <int>(); groupIds = new List <int>(); IList <int> propIds = new List <int>(); foreach (var item in allIds) { if (item.Contains("TYPE")) { typeIds.Add(Int32.Parse(item.Replace("TYPE_", ""))); } if (item.Contains("SUBCLASS")) { classIds.Add(Int32.Parse(item.Replace("SUBCLASS_", ""))); } if (item.Contains("CLASS") && !item.Contains("SUBCLASS")) { groupIds.Add(Int32.Parse(item.Replace("CLASS_", ""))); } if (item.Contains("GROUP")) { subclassIds.Add(Int32.Parse(item.Replace("GROUP_", ""))); } if (item.Contains("PROPERTY")) { propIds.Add(Int32.Parse(item.Replace("PROPERTY_", ""))); } } /* * Idem u bazu u MaterialTaxonomy i tamo za materijale koje imam u resultsu radim where po kriterijumima za classificationIds * i to sto dobijem radim INTERSECT sa results od gore, a ovaj results ispod komentarisem */ taxonomyResults = context.MaterialTaxonomyAll.AllAsNoTracking.Where(t => resultIds.Contains(t.ID)); taxonomyResultsL1 = new List <MaterialTaxonomy>(); taxonomyResultsL2 = new List <MaterialTaxonomy>(); taxonomyResultsL3 = new List <MaterialTaxonomy>(); taxonomyResultsL4 = new List <MaterialTaxonomy>(); taxonomyResultIds = new List <int>(); if (typeIds.Count > 0) { taxonomyResultsL1 = taxonomyResults.Where(l1 => l1.Level1 != null && typeIds.Contains((int)l1.Level1)); } if (groupIds.Count > 0) { taxonomyResultsL2 = taxonomyResults.Where(l2 => l2.Level2 != null && groupIds.Contains((int)l2.Level2)); } if (classIds.Count > 0) { taxonomyResultsL3 = taxonomyResults.Where(l3 => l3.Level3 != null && classIds.Contains((int)l3.Level3)); } if (subclassIds.Count > 0) { taxonomyResultsL4 = taxonomyResults.Where(l4 => l4.Level4 != null && subclassIds.Contains((int)l4.Level4)); } taxonomyResultIds = taxonomyResultsL1.Select(i1 => i1.ID).ToList() .Union(taxonomyResultsL2.Select(i2 => i2.ID).ToList()) .Union(taxonomyResultsL3.Select(i3 => i3.ID).ToList()) .Union(taxonomyResultsL4.Select(i4 => i4.ID).ToList()); IList <int> intersectIds = resultIds.Intersect(taxonomyResultIds).Distinct().ToList(); results = results.Where(r => intersectIds.Contains(r.Id)); //results = results.Where(m => (typeIds.Count > 0 && m.type_ID != null && typeIds.Contains((int)m.type_ID)) // || (classIds.Count > 0 && m.class_ID != null && classIds.Contains((int)m.class_ID)) // || (groupIds.Count > 0 && m.group_ID != null && groupIds.Contains((int)m.group_ID)) // || (subclassIds.Count > 0 && m.subClass_ID != null && subclassIds.Contains((int)m.subClass_ID)) // ); if (propIds.Count > 0) { results = results.Where(r => r.prop_IDs != null && CheckIDs(r.prop_IDs, propIds)); } classificationSelection = typeIds.Concat(classIds).Concat(groupIds).Concat(subclassIds).Concat(propIds).ToList(); resultIds = null; } if (filters.FromBrowse) { if (filters.ClasificationId != 0) { switch (filters.ClasificationTypeId) { case 1: results = results.Where(m => m.type_ID == filters.ClasificationId); taxonomyResults = taxonomyResults.Where(m => m.Level1 == filters.ClasificationId); break; case 2: results = results.Where(m => m.group_ID == filters.ClasificationId); taxonomyResults = taxonomyResults.Where(m => m.Level2 == filters.ClasificationId); break; case 3: results = results.Where(m => m.class_ID == filters.ClasificationId); taxonomyResults = taxonomyResults.Where(m => m.Level3 == filters.ClasificationId); break; case 4: results = results.Where(m => m.subClass_ID == filters.ClasificationId); taxonomyResults = taxonomyResults.Where(m => m.Level4 == filters.ClasificationId); break; default: break; } resultIds = null; } } HttpContext.Current.Session["ClassificationSelection"] = classificationSelection; // Inlude source filters if (filters.Source != null && filters.Source != "") { int sourceId; int?sourceDatabookId = null; if (filters.Source != "0") { IList <string> allSourceIds = filters.Source.Split(',').ToList(); if (allSourceIds.Count > 1) { sourceId = allSourceIds[0] != "" ? int.Parse(allSourceIds[0]) : 0; sourceDatabookId = allSourceIds[1] != "" ? int.Parse(allSourceIds[1]) : 0; } else { sourceId = allSourceIds[0] != "" ? int.Parse(allSourceIds[0]) : 0; } } else { sourceId = 0; sourceDatabookId = null; } if (sourceId != 0) { results = results.Where(m => m.source_IDs != null && m.source_IDs.Contains(string.Concat(",", sourceId.ToString(), ","))); resultIds = null; } if (sourceDatabookId != null && sourceDatabookId != 0) { results = results.Where(m => m.databook_IDs != null && m.databook_IDs.Contains(string.Concat(",", sourceDatabookId.ToString(), ","))); resultIds = null; } } //// Inlude column filters SearchFilterColumnsAll columnFilters = (SearchFilterColumnsAll)System.Web.HttpContext.Current.Session["SearchFilterColumnsAll"]; if (columnFilters != null) { foreach (SearchFilterColumns f in columnFilters.AllFilters.Where(c => c.Filter != null && c.Filter.Trim() != "")) { string oneFilter = f.Filter.Trim().ToUpper(); if (f.Name == "Material Name") { results = results.Where(m => m.material_designation != null && m.material_designation.ToUpper().Contains(oneFilter)); resultIds = null; } else if (f.Name == "Type") { results = results.Where(m => m.material_type != null && m.material_type.ToUpper().Contains(oneFilter)); resultIds = null; } else if (f.Name == "Class") { results = results.Where(m => m.material_group != null && m.material_group.ToUpper().Contains(oneFilter)); resultIds = null; } else if (f.Name == "Subclass") { results = results.Where(m => m.material_class != null && m.material_class.ToUpper().Contains(oneFilter)); resultIds = null; } else if (f.Name == "Group") { results = results.Where(m => m.material_subClass != null && m.material_subClass.ToUpper().Contains(oneFilter)); resultIds = null; } else if (f.Name == "UNS No.") { results = results.Where(m => m.UNS != null && m.UNS.ToUpper().Contains(oneFilter)); resultIds = null; } else if (f.Name == "CAS RN") { results = results.Where(m => m.CAS_RN != null && m.CAS_RN.ToUpper().Contains(oneFilter)); resultIds = null; } } } /*adv search*/ if (advFilters != null && advFilters.AllFilters != null && advFilters.AllFilters.Count > 0) { string sessionId = System.Web.HttpContext.Current.Session["TotalMateriaSession"].ToString(); IQueryable <EquivalentProperty> propIds = context.EquivalentProperties.AllAsNoTracking; IQueryable <EquivalentMaterial> matIds = context.EquivalentMaterials.AllAsNoTracking; IEnumerable <int> materialIds = context.AdvSearchResults.GetMaterialsByAdvancedSearch(false, advFilters, sessionId, propIds, matIds); IEnumerable <int> matVisibleIds = results.Select(n => n.Id); materialIds = materialIds.Where(n => matVisibleIds.Contains(n)); IEnumerable <int> resTM = context.FullTextSearch.GetMaterialsByMaterialIds(materialIds).Select(n => n.Id); results = results.Where(n => resTM.Contains(n.Id)); resultIds = null; } // Eval query and prepare final results if (filters.FromBrowse) { // From taxonomy table IList <int> tmpList = null; if (resultIds == null) { tmpList = taxonomyResults.Select(m => m.ID).Distinct().ToList(); } else { tmpList = resultIds.Distinct().ToList(); } HttpContext.Current.Session["ClassificationRecordsCount"] = tmpList; if (request.Sort.PropertyName == "Name") { IList <SampleMaterialModel> retListTemp = taxonomyResults .OrderBy(l => l.ID) .ThenBy(l1 => l1.Level1Name) .ThenByDescending(l4 => l4.Level4Name) .ThenByDescending(l3 => l3.Level3Name) .ThenByDescending(l2 => l2.Level2Name) .Select(m => new SampleMaterialModel() { Id = m.ID, Name = m.MaterialName, TypeName = m.Level1Name, GroupName = m.Level2Name, ClassName = m.Level3Name, SubClassName = m.Level4Name, UNS = null, CAS_RN = null }) .ToList(); IList <SampleMaterialModel> retList = new List <SampleMaterialModel>(); foreach (int matId in tmpList) { SampleMaterialModel mResult = retListTemp.Where(r => r.Id == matId).FirstOrDefault(); if (mResult != null) { retList.Add(new SampleMaterialModel() { Id = mResult.Id, Name = mResult.Name, TypeName = mResult.TypeName, GroupName = mResult.GroupName, ClassName = mResult.ClassName, SubClassName = mResult.SubClassName }); } } model.ListOfMaterials = PagerSearch <SampleMaterialModel>(request.Pager, retList.AsQueryable(), tmpList.Count).ToList(); } else { model.ListOfMaterials = taxonomyResults.AsQueryable().Slice(request).Select(m => new SampleMaterialModel() { Id = m.ID, Name = m.MaterialName, TypeName = m.Level1Name, GroupName = m.Level2Name, ClassName = m.Level3Name, SubClassName = m.Level4Name, UNS = null, CAS_RN = null }) .ToList(); } } else { IList <int> tmpList = null; if (resultIds == null) { tmpList = results.Select(m => m.Id).ToList(); } else { tmpList = resultIds; } HttpContext.Current.Session["ClassificationRecordsCount"] = tmpList; if (request.Sort.PropertyName == "Name") { // If search is not "by taxonomy' use FullTextSearch, else use materialTaxonomy table if (typeIds.Count() == 0 && groupIds.Count() == 0 && classIds.Count == 0 && subclassIds.Count() == 0) { IQueryable <SampleMaterialModel> retList = results.Select(m => new SampleMaterialModel() { Id = m.Id, Name = m.material_designation, TypeName = m.material_type, GroupName = m.material_group, ClassName = m.material_class, SubClassName = m.material_subClass, UNS = m.UNS, CAS_RN = m.CAS_RN }) .AsQueryable(); model.ListOfMaterials = PagerSearch <SampleMaterialModel>(request.Pager, retList, tmpList.Count).ToList(); } else { IEnumerable <MaterialTaxonomy> tr = context.MaterialTaxonomyAll.AllAsNoTracking; IEnumerable <MaterialTaxonomy> tr1 = new List <MaterialTaxonomy>(); IEnumerable <MaterialTaxonomy> tr2 = new List <MaterialTaxonomy>(); IEnumerable <MaterialTaxonomy> tr3 = new List <MaterialTaxonomy>(); IEnumerable <MaterialTaxonomy> tr4 = new List <MaterialTaxonomy>(); if (typeIds.Count > 0) { tr1 = tr.Where(l1 => l1.Level1 != null && typeIds.Contains((int)l1.Level1)); } if (groupIds.Count > 0) { tr2 = tr.Where(l2 => l2.Level2 != null && groupIds.Contains((int)l2.Level2)); } if (classIds.Count > 0) { tr3 = tr.Where(l3 => l3.Level3 != null && classIds.Contains((int)l3.Level3)); } if (subclassIds.Count > 0) { tr4 = tr.Where(l4 => l4.Level4 != null && subclassIds.Contains((int)l4.Level4)); } IList <Tuple <int, string, string, string, string, string> > trs = tr1.Select(i1 => new Tuple <int, string, string, string, string, string>(i1.ID, i1.MaterialName, i1.Level1Name, i1.Level2Name, i1.Level3Name, i1.Level4Name)) .Union(tr2.Select(i2 => new Tuple <int, string, string, string, string, string>(i2.ID, i2.MaterialName, i2.Level1Name, i2.Level2Name, i2.Level3Name, i2.Level4Name))) .Union(tr3.Select(i3 => new Tuple <int, string, string, string, string, string>(i3.ID, i3.MaterialName, i3.Level1Name, i3.Level2Name, i3.Level3Name, i3.Level4Name))) .Union(tr4.Select(i4 => new Tuple <int, string, string, string, string, string>(i4.ID, i4.MaterialName, i4.Level1Name, i4.Level2Name, i4.Level3Name, i4.Level4Name))) .ToList(); IList <SampleMaterialModel> retListTemp = trs .OrderBy(l => l.Item1) .ThenBy(l1 => l1.Item3) .ThenByDescending(l4 => l4.Item6) .ThenByDescending(l3 => l3.Item5) .ThenByDescending(l2 => l2.Item4) .Select(m => new SampleMaterialModel() { Id = m.Item1, Name = m.Item2, TypeName = m.Item3, GroupName = m.Item4, ClassName = m.Item5, SubClassName = m.Item6, UNS = null, CAS_RN = null }) .ToList(); IList <SampleMaterialModel> retList = new List <SampleMaterialModel>(); foreach (int matId in tmpList) { SampleMaterialModel mResult = retListTemp.Where(r => r.Id == matId).FirstOrDefault(); if (mResult != null) { retList.Add(new SampleMaterialModel() { Id = mResult.Id, Name = mResult.Name, TypeName = mResult.TypeName, GroupName = mResult.GroupName, ClassName = mResult.ClassName, SubClassName = mResult.SubClassName }); } } model.ListOfMaterials = PagerSearch <SampleMaterialModel>(request.Pager, retList.AsQueryable(), tmpList.Count).ToList(); } } else { model.ListOfMaterials = results.AsQueryable().Slice(request).Select(m => new SampleMaterialModel() { Id = m.Id, Name = m.material_designation, TypeName = m.material_type, GroupName = m.material_group, ClassName = m.material_class, SubClassName = m.material_subClass, UNS = m.UNS, CAS_RN = m.CAS_RN }) .ToList(); } } model.Descriptor = request; model.Filter = new SearchResultsCondition(); model.Filter.FullText = filters.filter; if (classificationSelection.Count > 0) { HttpContext.Current.Session["NodeNames"] = context.Trees.GetTreeNodesNames(classificationSelection); } else { HttpContext.Current.Session["NodeNames"] = new Dictionary <int, string>(); } return(model); }