private BizBus.Filter.Filter GetFilter() { BizBus.Filter.Filter filter = new BizBus.Filter.Filter(); And and = new And(); filter.Matcher = and; if (this.BizQuery == null) { return(filter); } //读取默认值和传入的映射 Dictionary <string, object> items = new Dictionary <string, object>(); Dictionary <string, DataModel.BizQueryItem> QueryItems = new Dictionary <string, DataModel.BizQueryItem>(); if (this.BizQuery.QueryItems == null) { this.BizQuery.QueryItems = new DataModel.BizQueryItem[] {} } ; foreach (DataModel.BizQueryItem QueryItem in this.BizQuery.QueryItems) { QueryItems.Add(QueryItem.PropertyName, QueryItem); if (QueryItem.FilterType == OThinker.H3.DataModel.FilterType.SystemParam) { items.Add(QueryItem.PropertyName, SheetUtility.GetSystemParamValue(this.UserValidator, QueryItem.DefaultValue)); } else { //设置默认值 if (!string.IsNullOrWhiteSpace(QueryItem.DefaultValue)) { items.Add(QueryItem.PropertyName, SheetUtility.GetSystemParamValue(this.UserValidator, QueryItem.DefaultValue)); } //设置映射传入的值 if (this.InputMapping != null) { if (this.InputMapping.ContainsKey(QueryItem.PropertyName)) { if (items.ContainsKey(QueryItem.PropertyName)) { items[QueryItem.PropertyName] = this.InputMapping[QueryItem.PropertyName]; } else { items.Add(QueryItem.PropertyName, this.InputMapping[QueryItem.PropertyName]); } } } } } //页面传过来的值 string FilterStr = Request["Filters"] ?? ""; if (!string.IsNullOrWhiteSpace(FilterStr)) { Dictionary <string, string> Filters = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, string> >(FilterStr); foreach (string key in Filters.Keys) { if (!QueryItems.ContainsKey(key)) { continue; } DataModel.BizQueryItem QueryItem = QueryItems[key]; if (QueryItem.FilterType == OThinker.H3.DataModel.FilterType.SystemParam) { continue; } if (QueryItem.Visible == OThinker.Data.BoolMatchValue.False) { continue; } if (items.ContainsKey(key)) { items[key] = Filters[key]; } else { items.Add(key, Filters[key]); } } } //添加到过滤集合 foreach (string key in items.Keys) { DataModel.BizQueryItem QueryItem = QueryItems[key]; if (QueryItem.FilterType == OThinker.H3.DataModel.FilterType.Equals || QueryItem.FilterType == OThinker.H3.DataModel.FilterType.SystemParam) { and.Add(new ItemMatcher(key, OThinker.Data.ComparisonOperatorType.Equal, items[key])); } else if (QueryItem.FilterType == OThinker.H3.DataModel.FilterType.Contains) { and.Add(new ItemMatcher(key, OThinker.Data.ComparisonOperatorType.Contain, items[key])); } else if (QueryItem.FilterType == OThinker.H3.DataModel.FilterType.Scope) { string[] vals = items[key].ToString().Split(';'); if (vals.Length > 1) { and.Add(new ItemMatcher(key, OThinker.Data.ComparisonOperatorType.NotBelow, vals[0])); } if (vals.Length > 2) { and.Add(new ItemMatcher(key, OThinker.Data.ComparisonOperatorType.NotAbove, vals[1])); } } } //设置排序 filter.AddSortBy(new SortBy(this.BizQuery.Columns.FirstOrDefault().PropertyName, SortDirection.Ascending)); return(filter); } }