public SearchData(string column, string term, DataTable table, SearchRule rule) { SearchColumn = column; SearchTerm = term; SearchTable = table; SearchRule = rule; }
public UserByUsernameQuery(string username) : base() { search_rules = new SearchRule[] { new SearchRule { condition = $"UserName == \"{username}\"" } }; ordering_rules = new OrderingRule[] { }; }
public static string SqlSearchFromRule(string column, string key, SearchRule rule) { var sql = ""; switch (rule) { case SearchRule.ContainsKey: sql = column + " LIKE '%" + key + "%'"; break; case SearchRule.EqualsKey: sql = column + " = '" + key + "'"; break; case SearchRule.BeginsWith: sql = column + " LIKE '" + key + "%'"; break; case SearchRule.EndsWith: sql = column + " LIKE '%" + key + "'"; break; } return(sql); }
private TreeNode CreateNode(SearchRule rule) { TreeNode frontNode = new TreeNode(rule.NodeDisplay); frontNode.ImageIndex = _iconRegistry.Lookup(rule.GetType()); frontNode.SelectedImageIndex = frontNode.ImageIndex; frontNode.Tag = rule; return(frontNode); }
static void Main(string[] args) { List <SearchRule> response = new List <SearchRule>(); var str = @"已出台CRM开发推广应用计划并发布,每天核查反馈进度情况 已完成初稿制定 跟石总沟通,暂无计划客户 团建办法、督导办法没有定稿,岗位职业考核周一督促人事组织 数据量较大,利用节假日完成 会议前策划书已提交 完成 完成 材料进销存和三大材料调差产品配置完毕。"; List <string> keys = new List <string>() { "\r\n", "\t", " " }; keys.ForEach(x => { SearchRule searchRule = new SearchRule() { SearchKey = x, SearchCount = 0 }; str.GetStringMatchCount(searchRule); response.Add(searchRule); }); var sp = response.OrderBy(o => o.SearchCount).FirstOrDefault(); var spmax = response.OrderByDescending(o => o.SearchCount).FirstOrDefault(); var rs = str.GetStringSingleColumn(new List <string>() { sp.SearchKey }); rs.ForEach(x => { var columns = x.GetStringSingleColumn(new List <string>() { spmax.SearchKey }); System.Console.WriteLine($"这一行共计:{columns.Count}列"); columns.ForEach(p => { System.Console.WriteLine($"值:{p.ToStringExtension()}"); }); }); //response.OrderByDescending(p => p.SearchCount).ToList().ForEach(o => { // var s = o.SearchKey; // var c = o.SearchCount; // System.Console.WriteLine($"key:{o.SearchKey.ToString()} count={o.SearchCount}"); //}); System.Console.ReadLine(); }
public void EditNode(TreeNode node) { if (node == null || !(node.Tag is SearchRule)) { return; } SearchRule rule = node.Tag as SearchRule; if (rule is ByteTagRule) { EditIntegralNode <ByteTagRule, TagNodeByte>(node, rule as ByteTagRule, "Byte"); } else if (rule is ShortTagRule) { EditIntegralNode <ShortTagRule, TagNodeShort>(node, rule as ShortTagRule, "Short"); } else if (rule is IntTagRule) { EditIntegralNode <IntTagRule, TagNodeInt>(node, rule as IntTagRule, "Int"); } else if (rule is LongTagRule) { EditIntegralNode <LongTagRule, TagNodeLong>(node, rule as LongTagRule, "Long"); } else if (rule is FloatTagRule) { EditFloatNode <FloatTagRule, TagNodeFloat>(node, rule as FloatTagRule, "Float"); } else if (rule is DoubleTagRule) { EditFloatNode <DoubleTagRule, TagNodeDouble>(node, rule as DoubleTagRule, "Double"); } else if (rule is StringTagRule) { EditStringNode(node, rule as StringTagRule, "String"); } else if (rule is WildcardRule) { EditWildcardNode(node, rule as WildcardRule, "Wildcard"); } }
public void DeleteNode(TreeNode node) { if (node == null || !(node.Tag is SearchRule)) { return; } TreeNode parent = node.Parent; if (parent == null || !(parent.Tag is GroupRule)) { return; } GroupRule parentData = parent.Tag as GroupRule; SearchRule nodeData = node.Tag as SearchRule; parentData.Rules.Remove(nodeData); parent.Nodes.Remove(node); }
/// <summary> /// 分页获取数据 /// </summary> /// <param name="rule">搜索规则</param> /// <returns></returns> public BasePagedResult <UserInfo> Search(SearchRule rule) { var result = new BasePagedResult <UserInfo>(); try { //数据库交互处理… //模拟数据 var list = new List <UserInfo> { new UserInfo { UserName = "******", Tel = "13556598568", Address = "福建福州", Email = "13556598568.qq.com" }, new UserInfo { UserName = "******", Tel = "13556598568", Address = "福建福州", Email = "13556598568.qq.com" }, new UserInfo { UserName = "******", Tel = "13556598568", Address = "福建福州", Email = "13556598568.qq.com" } }; var paged = new PagedList <UserInfo>(list, rule.PageIndex, rule.PageSize, list.Count); result.Result.List = paged; result.Result.TotalCount = paged.TotalCount; result.Result.PageSize = paged.PageSize; result.Result.PageIndex = paged.PageIndex; result.Result.Params = rule; result.Msg = "获取成功!"; return(result); } catch (Exception ex) { result.SetError(ex.Message, 5000); return(result); } }
/// <summary> /// 分页获取数据 /// </summary> /// <param name="rule">搜索规则</param> /// <returns></returns> public BasePagedResult <UserInfo> Search(SearchRule rule) { var result = _userInfoService.Search(rule); return(result); }
/// <summary> /// 分页获取数据 /// </summary> /// <param name="rule">搜索规则</param> /// <returns></returns> public JsonResult Search(SearchRule rule) { var result = _userInfoService.Search(rule); return(new JsonFormatResult(result, JsonRequestBehavior.AllowGet)); }
private int Searching(List <PairWithIndex> cats, List <PairWithIndex> mice, List <Pair> cheeses, out List <List <Pair> > catsPath, out List <List <Pair> > micePath, SearchRule rule) { // initialize int count = 0; int height = board.GetLength(0); int width = board.GetLength(1); BoardState current = new BoardState(null, new List <BoardState>(), cats, mice, cheeses); current.Gn = 0; current.Hn = 0; List <BoardState> searchList = new List <BoardState>(); searchList.Add(current); BoardState checkBoard; micePath = new List <List <Pair> >(); catsPath = new List <List <Pair> >(); while (searchList.Count > 0) { count++; if (searchRule == SearchRule.AStar1 || searchRule == SearchRule.AStar2 || searchRule == SearchRule.AStar3) { searchList.Sort(new myComparer()); } checkBoard = searchList[0]; searchList.Remove(searchList[0]); // check cheeses List <Pair> currentCheeses; int cheesesNum = CheckCheeses(checkBoard.mice, checkBoard.cheeses, out currentCheeses); if (cheesesNum == 0) { continue; } // check mice List <PairWithIndex> currentMice; int miceNum = CheckMice(checkBoard.mice, checkBoard.cats, checkBoard, out currentMice, micePath); if (miceNum == 0) { for (int i = 0; i < checkBoard.cats.Count; i++) { List <Pair> catPath = new List <Pair>(); BoardState temp = checkBoard; int index = checkBoard.cats[i].index; while (temp.parent != null) { for (int k = 0; k < temp.cats.Count; k++) { if (temp.cats[k].index == index) { catPath.Insert(0, temp.cats[k].p); break; } } temp = temp.parent; } catsPath.Add(catPath); } break; } // mice move, only one possibility List <PairWithIndex> miceMove = new List <PairWithIndex>(); for (int i = 0; i < currentMice.Count; i++) { // mice's next step Pair p = Mouse.NextStep(currentMice[i].p, currentCheeses, width, height); int index = currentMice[i].index; PairWithIndex nextStep = new PairWithIndex(p, index); miceMove.Add(nextStep); } // cats move, expand all possible states List <List <PairWithIndex> > catsCandidateSet = new List <List <PairWithIndex> >(); for (int i = 0; i < checkBoard.cats.Count; i++) { List <PairWithIndex> oneCatMove = new List <PairWithIndex>(); List <Pair> candidates = Cat.FindCandidates(checkBoard.cats[i].p, board); for (int j = 0; j < candidates.Count; j++) { Pair p = candidates[j]; int index = checkBoard.cats[i].index; oneCatMove.Add(new PairWithIndex(p, index)); } catsCandidateSet.Add(oneCatMove); } List <List <PairWithIndex> > catsMove = new List <List <PairWithIndex> >(); Expand(catsMove, catsCandidateSet, new List <PairWithIndex>(), 0); switch (searchRule) { case SearchRule.DFS: DFS(searchList, checkBoard, catsMove, miceMove, currentCheeses); break; case SearchRule.BFS: BFS(searchList, checkBoard, catsMove, miceMove, currentCheeses); break; case SearchRule.AStar1: AStar1(searchList, checkBoard, catsMove, miceMove, currentCheeses); break; case SearchRule.AStar2: AStar2(searchList, checkBoard, catsMove, miceMove, currentCheeses); break; case SearchRule.AStar3: AStar3(searchList, checkBoard, catsMove, miceMove, currentCheeses); break; } } return(count); }
private int IDDFS(List <PairWithIndex> cats, List <PairWithIndex> mice, List <Pair> cheeses, out List <List <Pair> > catsPath, out List <List <Pair> > micePath, SearchRule searchRule) { // initialize int count = 0; BoardState current = new BoardState(null, new List <BoardState>(), cats, mice, cheeses); current.Gn = 0; current.Hn = 0; micePath = new List <List <Pair> >(); catsPath = new List <List <Pair> >(); int limit = 0; int maxDepth = -1; while (catsPath.Count == 0) { if (maxDepth >= 0) { break; } count += DLS(current, cheeses, catsPath, micePath, limit, out maxDepth); limit++; } return(count); }
/// <summary> /// 检索 /// </summary> /// <param name="paragragh"></param> /// <returns></returns> public static List <LocAndValue <String> > Search(AnnouceDocument doc, SearchRule rule) { var rtn = new List <LocAndValue <String> >(); if (rule.BaseWord.Description.Count == 0) { //关键字,没有任何描述 doc.CustomerList = LocateCustomerWord(doc.root, rule.BaseWord.Word, "关键字"); doc.nermap.Anlayze(doc); } foreach (var paragragh in doc.nermap.ParagraghlocateDict.Values) { for (int baseIdx = 0; baseIdx < paragragh.NerList.Count; baseIdx++) { var evaluate = paragragh.NerList[baseIdx]; if (!IsMatch(rule.BaseWord, evaluate)) { continue; } if (rule.SearchForward) { //向前 for (int ScanIdx = baseIdx + 1; ScanIdx < paragragh.NerList.Count; ScanIdx++) { evaluate = paragragh.NerList[ScanIdx]; if (IsMatch(rule.Target, evaluate)) { if (rule.Validator == null) { rtn.Add(evaluate); break; } else { if (rule.Validator(evaluate)) { rtn.Add(evaluate); break; } } } } } else { //向后 for (int ScanIdx = baseIdx - 1; ScanIdx > -1; ScanIdx--) { evaluate = paragragh.NerList[ScanIdx]; if (IsMatch(rule.Target, evaluate)) { if (rule.Validator == null) { rtn.Add(evaluate); break; } else { if (rule.Validator(evaluate)) { rtn.Add(evaluate); break; } } } } } } } return(rtn); }