private static List <Expression> GetFilterExpress(FindIndicator queryContditon) { List <Expression> list = new List <Expression>(); Expression lhs = null; switch (queryContditon.findOptionFlag) { case FindOptionFlag.None: if (!String.IsNullOrEmpty(queryContditon.content)) { String[] strArray = queryContditon.content.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); StringBuilder builder = new StringBuilder(); foreach (String str in strArray) { builder.AppendFormat("%{0}%", str.ToUpper()); if (lhs != null) { lhs = Expression.And(lhs, Expression.Like("STR_MACRONAME", builder.ToString())); } else { lhs = Expression.Like("STR_MACRONAME", builder.ToString()); } builder.Length = 0; } } break; case FindOptionFlag.CaseSensitive: if (!String.IsNullOrEmpty(queryContditon.content)) { String[] strArray2 = queryContditon.content.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); StringBuilder builder2 = new StringBuilder(); foreach (String str2 in strArray2) { builder2.AppendFormat("%{0}%", str2); if (lhs != null) { lhs = Expression.And(lhs, Expression.Like("STR_MACRONAME", builder2.ToString())); } else { lhs = Expression.Like("STR_MACRONAME", builder2.ToString()); } builder2.Length = 0; } } break; case FindOptionFlag.FullText: if (!String.IsNullOrEmpty(queryContditon.content)) { String[] strArray7 = queryContditon.content.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < strArray7.Length; i++) { String text1 = strArray7[i]; if (lhs != null) { lhs = Expression.And(lhs, Expression.Eq("STR_MACRONAME", queryContditon.content.ToUpper())); } else { lhs = Expression.Eq("STR_MACRONAME", queryContditon.content.ToUpper()); } } } break; case FindOptionFlag.All: if (!String.IsNullOrEmpty(queryContditon.content)) { String[] strArray8 = queryContditon.content.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); for (int j = 0; j < strArray8.Length; j++) { String text2 = strArray8[j]; if (lhs != null) { lhs = Expression.And(lhs, Expression.Eq("STR_MACRONAME", queryContditon.content)); } else { lhs = Expression.Eq("STR_MACRONAME", queryContditon.content); } } } break; } list.Add(lhs); if (queryContditon.dataSource.Length > 0) { list.Add(Expression.Like("STR_DATASOURCE", String.Format("%{0}%", queryContditon.dataSource))); } switch (queryContditon.findContentFlag) { case FindContentFlag.NodeName: { int num5 = 1; list.Add(Expression.Eq("STR_FLAG", num5.ToString())); break; } case FindContentFlag.IndicatorName: { int num6 = 0; list.Add(Expression.Eq("STR_FLAG", num6.ToString())); break; } } if (queryContditon.excludeContent.Length > 0) { list.Add(Expression.NotLike("STR_MACRONAME", String.Format("%{0}%", queryContditon.excludeContent))); } return(list); }
public static DataSet GetGivenFieldMacroData(FindIndicator queryContditon, String[] fields) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); DataSet set = new DataSet(); List <DataTransmission> dtList = null; DataTransmission item = null; try { item = new DataTransmission(); item.MaxResult = 0x7fffffff; if ((fields != null) && (fields.Length > 0)) { item.Fields = fields; } item.Filters = GetFilterExpress(queryContditon); dtList = new List <DataTransmission>(); if (queryContditon.findRange == MacroDataType.All) { item.DataSource = "EDB_MACRO_INDICATOR_TEST"; dtList.Add(item); DataTransmission transmission2 = new DataTransmission(); transmission2.MaxResult = 0x7fffffff; transmission2.Fields = fields; transmission2.DataSource = "EDB_GLOBAL_INDICATOR_TEST"; transmission2.Filters = item.Filters; dtList.Add(transmission2); DataTransmission transmission3 = new DataTransmission(); transmission3.MaxResult = 0x7fffffff; transmission3.Fields = fields; transmission3.DataSource = "EDB_INDUSTRY_INDICATOR_TEST"; transmission3.Filters = item.Filters; dtList.Add(transmission3); } else { item.DataSource = MongoDBConstant.DicTreeSource[queryContditon.findRange]; dtList.Add(item); } set = _uniqueQuery.Query(dtList); } catch (Exception exception) { //EMLoggerHelper.Write(exception); } finally { stopwatch.Stop(); //EMLoggerHelper.Write("搜索耗时{0}", new object[] { stopwatch.ElapsedMilliseconds }); if (item != null) { item.Clear(); } if (dtList != null) { dtList.Clear(); } } return(set); }