private void treeViewOntology_AfterSelect(object sender, TreeViewEventArgs e) { listViewResult.Items.Clear(); if (treeViewOntology.SelectedNode.Parent != null) { if (treeViewOntology.SelectedNode.Parent.Name == "rawview") { XDocument xDoc = dataContext.ExecuteQuery("SELECT * WHERE { ?x <" + treeViewOntology.SelectedNode.Name + "> ?y.}"); foreach (var sparqlResultRow in xDoc.SparqlResultRows()) { string resultX = sparqlResultRow.GetColumnValue("x").ToString(); string resultY = sparqlResultRow.GetColumnValue("y").ToString(); listViewResult.Items.Add(resultX).SubItems.AddRange(new string[] { treeViewOntology.SelectedNode.Name, resultY }); } } if (treeViewOntology.SelectedNode.Parent.Name == "wellform") { XDocument xDoc = dataContext.ExecuteQuery("SELECT * WHERE { ?x <" + treeViewOntology.SelectedNode.Name + "> ?y.}"); foreach (var sparqlResultRow in xDoc.SparqlResultRows()) { string resultX = sparqlResultRow.GetColumnValue("x").ToString(); resultX = resultX.Replace(URI + "/", ""); //resultX = resultX.Remove(0,resultX.IndexOf("#") + 1); string resultY = sparqlResultRow.GetColumnValue("y").ToString(); resultY = resultY.Replace(URI + "/", ""); //resultY = resultY.Remove(0, resultY.IndexOf("#") + 1); listViewResult.Items.Add(resultX).SubItems.AddRange(new string[] { treeViewOntology.SelectedNode.Name.Replace(URI + "/", "").Replace("#", ""), resultY }); } } } }
private void CRMForm_Load(object sender, EventArgs e) { // Initialise license and stores directory location Configuration.Register(); //create a unique store name var storeName = "CRM_Ontology"; //connection string to the BrightstarDB service string connectionString = string.Format(@"Type=embedded;storesDirectory={0};StoreName={1};", Configuration.StoresDirectory, storeName); dataContext = new CRMOntologyContext(connectionString); client = BrightstarService.GetClient(connectionString); //getPredicates XDocument xDoc = dataContext.ExecuteQuery("SELECT DISTINCT ?predicate WHERE { ?x ?predicate ?y.}"); foreach (var sparqlResultRow in xDoc.SparqlResultRows()) { string result = sparqlResultRow.GetColumnValue("predicate").ToString(); //beautify if (result.IndexOf(URI) >= 0) { treeViewOntology.Nodes[0].Nodes[0].Nodes.Add(result, result.Replace(URI + "/", "").Replace("#", "")); treeViewOntology.Nodes[0].Nodes[1].Nodes.Add(result, result.Replace(URI + "/", "").Replace("#", "")); } } }