Removed old sample queries file that was no longer used, fixed issue where graph explorer did not show an empty graph if there were no matches, some cleanup

This commit is contained in:
Peter Villadsen 2020-08-08 17:21:58 -07:00
Родитель ee3fd27ffe
Коммит 30e3cb1d16
5 изменённых файлов: 17 добавлений и 64 удалений

Просмотреть файл

@ -1,53 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
namespace XppReasoningWpf
{
class SampleQueries
{
public static List<string> AddQueries(string rootDirectory)
{
var result = new List<string>();
var assembly = Assembly.GetExecutingAssembly();
// Get all the xq streams??
var names = assembly.GetManifestResourceNames().Where(n => n.StartsWith("XppReasoningWpf.Queries", StringComparison.OrdinalIgnoreCase));
foreach (var queryName in names)
{
using (Stream s = assembly.GetManifestResourceStream(queryName))
{
var r = new StreamReader(s);
{
var c = r.ReadToEnd();
var parts = queryName.Split('.').ToList();
parts.RemoveAt(0); // Skip namespace
var extension = parts.Last();
parts.RemoveAt(parts.Count() - 1);
var name = parts.Last();
parts.RemoveAt(parts.Count() - 1);
string directoryPart = Path.Combine(parts.ToArray());
var directoryName = Path.Combine(rootDirectory, directoryPart);
Directory.CreateDirectory(directoryName);
var fullName = Path.Combine(directoryName, name + '.' + extension);
result.Add(fullName);
File.WriteAllText(fullName, c);
}
}
}
return result;
}
}
}

Просмотреть файл

@ -192,9 +192,10 @@ namespace SocratexGraphExplorer.Models
public string QueryFont => Properties.Settings.Default.QueryFont;
public void CreateNeo4jDriver(string password)
public IDriver CreateNeo4jDriver(string password)
{
this.Driver = GraphDatabase.Driver(string.Format("bolt://{0}:{1}", this.Server, this.Port), AuthTokens.Basic(this.Username, password));
return this.Driver;
}
public Model()
@ -249,10 +250,15 @@ namespace SocratexGraphExplorer.Models
if (driver == null)
return false;
var session = driver.AsyncSession();
var cursor = await session.RunAsync("match(c) return count(c)");
var list = await cursor.ToListAsync();
return list != null && list.Any();
try
{
await driver.VerifyConnectivityAsync();
return true;
}
catch
{
return false;
}
}
}
catch (Exception )
@ -469,10 +475,11 @@ namespace SocratexGraphExplorer.Models
public static HashSet<long> HarvestNodeIdsFromGraph(List<IRecord> records)
{
if (!records.Any())
return null;
var result = new HashSet<long>();
if (!records.Any())
return result;
App.Current.Dispatcher.Invoke(() =>
{
foreach (var record in records)

Просмотреть файл

@ -335,7 +335,6 @@ namespace SocratexGraphExplorer.ViewModels
this.model = model;
NodeSelected += UpdateNodeInfoPage;
EdgeSelected += UpdateEdgeInfoPage;
this.PropertyChanged += async (object sender, PropertyChangedEventArgs e) =>

Просмотреть файл

@ -55,7 +55,7 @@ namespace SocratexGraphExplorer.Views
this.SourceEditorBox.Content = this.ClassEditor;
}
private async void UserControl_Loaded(object sender, RoutedEventArgs e)
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
this.Header.Text = string.Format("{0} {1}", node.Labels[0], node.Properties["Name"] as string);
properties.Add(new PropertyItem() { Key = "Id", Value = node.Id.ToString() });

Просмотреть файл

@ -55,7 +55,7 @@ namespace SocratexGraphExplorer.Views
this.SourceEditorBox.Content = this.ClassEditor;
}
private async void UserControl_Loaded(object sender, RoutedEventArgs e)
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
this.Header.Text = string.Format("{0} {1}", node.Labels[0], node.Properties["Name"] as string);
properties.Add(new PropertyItem() { Key = "Id", Value = node.Id.ToString() });