internal void Process(Tag.Tag tag) { List <string> list = null; PermissionType pType; Enum.TryParse <PermissionType>(tag.TagType.ToString(), out pType); if (dicTable.TryGetValue(pType, out list)) { list.AddRange(tag.Table); } else { list = new List <string>(tag.Table); dicTable[pType] = list; } if (tag.Alias.Count > 0) { foreach (KeyValuePair <string, string> kv in tag.Alias) { dicA[kv.Key] = kv.Value; } } }
public List <Tag.Tag> GetTags() { List <Tag.Tag> tags = new List <Tag.Tag>(); TagTreeNode next = head.NextNode; TagTreeNode last = null; TagTreeNode cur = null; TagTreeNode lastPre = null; Tag.Tag tag = new Tag.Tag(); try { tag.TagType = (TagType)Enum.Parse(typeof(TagType), head.NodeKey); } catch { throw new Exception("SQL异常"); } while (next != null) { if (TagFactory.defaultTag == next.NodeKey) { //说明是数据 if (null == last) { cur = head; } else { cur = last; } // switch (cur.NodeKey) { case "select": tag.Fields.AddRange(next.NodeData); break; case "from": case "table": case "into": case "join": tag.Table.AddRange(next.NodeData); break; case "l_clause": { if (lastPre != null && lastPre.NodeKey == "into") { tag.Fields.AddRange(next.NodeData); } } break; case "as": { if (lastPre != null && lastPre.NodeData.Count > 0) { tag.Alias[lastPre.NodeData[lastPre.NodeData.Count - 1]] = next.NodeData[0]; } } break; case "field": { if (cur.NodeData.Count > 0) { tag.Alias[cur.NodeData[cur.NodeData.Count - 1]] = next.NodeData[0]; } } break; } // } else { TagType tagType; if (Enum.TryParse <TagType>(next.NodeKey, out tagType)) { //说明是操作类关键词 tags.Add(tag); tag = new Tag.Tag(); tag.TagType = tagType; } } lastPre = last; last = next; next = next.NextNode; } // tags.Add(tag); return(tags); }