public XElement GetQueryXml(WorkItemContext context, FieldList fields) { var parser = new LexalParser(this.QueryText); var nodes = parser.ProcessWherePart(); nodes.Optimize(); nodes.ExtractOperatorForward(); nodes.FixFields(fields); nodes.FillFieldTypes(fields); var manager = new ParameterManager(context); manager.EvalParameters(nodes); var xmlTransformer = new NodesToXml(nodes); return XElement.Parse(xmlTransformer.WriteXml()); }
public void RPN1() { XElement el = XElement.Parse(@"<f>select [System.Id], [Phoenix.DueDate], [Phoenix.MagicDueDate], [System.WorkItemType], [System.State], [System.Title], [System.IterationPath] from WorkItems where ([System.State] = 'New' or [System.State] = 'Active') and ([System.AssignedTo] = 'Ventsislav Mladenov' or [System.TeamProject] = 'TestProject') order by [System.Id]</f>"); var parser = new LexalParser(el.Value); var nodes = parser.ProcessWherePart(); nodes.Optimize(); nodes.ExtractOperatorForward(); var xmlTransformer = new NodesToXml(nodes); var result = xmlTransformer.WriteXml(); Console.WriteLine(result); Assert.Equal("<Group GroupOperator=\"And\">\r\n <Group GroupOperator=\"Or\">\r\n <Expression Column=\"System.State\" FieldType=\"0\" Operator=\"equals\">\r\n <String>New</String>\r\n </Expression>\r\n <Expression Column=\"System.State\" FieldType=\"0\" Operator=\"equals\">\r\n <String>Active</String>\r\n </Expression>\r\n </Group>\r\n <Group GroupOperator=\"Or\">\r\n <Expression Column=\"System.AssignedTo\" FieldType=\"0\" Operator=\"equals\">\r\n <String>Ventsislav Mladenov</String>\r\n </Expression>\r\n <Expression Column=\"System.TeamProject\" FieldType=\"0\" Operator=\"equals\">\r\n <String>TestProject</String>\r\n </Expression>\r\n </Group>\r\n</Group>", result); }
public void NodesToXml3() { string val = "where (([f] = 2 and [a] = 2) or [s] = 1) and ([b] = 3 or ([x] = 1 and [s] = 3))"; var parser = new LexalParser(val); var nodes = parser.ProcessWherePart(); nodes.Optimize(); nodes.ExtractOperatorForward(); var xmlTransformer = new NodesToXml(nodes); var output = xmlTransformer.WriteXml(); Console.WriteLine(output); }
public void NodesToXml2() { string val = "where ([f] = 2 and [a] = 2) or ([b] = 3 and [x] = 1)"; var parser = new LexalParser(val); var nodes = parser.ProcessWherePart(); nodes.Optimize(); nodes.ExtractOperatorForward(); var xmlTransformer = new NodesToXml(nodes); var output = xmlTransformer.WriteXml(); Console.WriteLine(output); Assert.Equal("<Group GroupOperator=\"Or\">\r\n <Group GroupOperator=\"And\">\r\n <Expression Column=\"f\" FieldType=\"0\" Operator=\"equals\">\r\n <Number>2</Number>\r\n </Expression>\r\n <Expression Column=\"a\" FieldType=\"0\" Operator=\"equals\">\r\n <Number>2</Number>\r\n </Expression>\r\n </Group>\r\n <Group GroupOperator=\"And\">\r\n <Expression Column=\"b\" FieldType=\"0\" Operator=\"equals\">\r\n <Number>3</Number>\r\n </Expression>\r\n <Expression Column=\"x\" FieldType=\"0\" Operator=\"equals\">\r\n <Number>1</Number>\r\n </Expression>\r\n </Group>\r\n</Group>", output); }
public void NodesToXml1() { string val = "where [f] = 2"; var parser = new LexalParser(val); var nodes = parser.ProcessWherePart(); nodes.Optimize(); nodes.ExtractOperatorForward(); var xmlTransformer = new NodesToXml(nodes); var output = xmlTransformer.WriteXml(); Console.WriteLine(output); Assert.Equal("<Expression Column=\"f\" FieldType=\"0\" Operator=\"equals\">\r\n <Number>2</Number>\r\n</Expression>", output); }
public void RPN4() { XElement el = XElement.Parse(@"<f>select [System.Id], [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State] from WorkItems where [System.TeamProject] = @project and [System.WorkItemType] <> '' and ([System.ChangedDate] < @today - 30 or [System.CreatedDate] > @today - 7) and [Microsoft.VSTS.Common.ResolvedBy] = @me and [System.WorkItemType] in ('Bug', 'Task') and [System.State] <> '' order by [System.Id]</f>"); var parser = new LexalParser(el.Value); var nodes = parser.ProcessWherePart(); nodes.Optimize(); nodes.ExtractOperatorForward(); var xmlTransformer = new NodesToXml(nodes); var result = xmlTransformer.WriteXml(); Console.WriteLine(result); }
public void RPN3() { string val = "where [Microsoft.VSTS.Common.ResolvedBy] = 'Ventsislav Mladenov' and [Microsoft.VSTS.CMMI.CalledBy] = 'Ventsislav Mladenov' or [Microsoft.VSTS.Common.ClosedBy] = 'Ventsislav Mladenov'"; var parser = new LexalParser(val); var nodes = parser.ProcessWherePart(); nodes.Optimize(); nodes.ExtractOperatorForward(); var xmlTransformer = new NodesToXml(nodes); var result = xmlTransformer.WriteXml(); Console.WriteLine(result); }